I'm trying to use regex to match numbers with thousand separators, but only if they are preceded with a -$
For example, I would like to match
-$1,200
-$750
But not
$1200
$750
From other answers, I'm able to use [0-9]{1,3}
to match numbers with thousand separators, but I can't figure out how to limit to only cases that are preceded with -$
. -\$[0-9]{1,3}
doesn't work.
Example on regex101
The particular string that I'm trying to get it to work on:
{"amount":1242,"amountFormatted":"-$1,242","currency":"USD","type":"PRICING","__typename":"PriceItem"},{"localizedTitle":"Fees","localizedExplanation":"This fee covers: "}