The regex is matching the currency properly, for instance $42,000,000 . However, if I write aaaa$42,000,000
or $42,000,000aaa
or aaa$42,000,000aaaa
it's also matching it which shouldn't be the case, it should match only when there are spaces around.
The regex I have is /\$(([1-9]\d{0,2}(,\d{3})*)|0)?(\,\d{1,2})?/g
I also tried with /\b\$(([1-9]\d{0,2}(,\d{3})*)|0)?(\,\d{1,2})?\b/g
but it's not working. Any suggestions?