I need to format input currency (with no decimal places) to standard way (like $XXX,XXX,XXX,XXX).
User can input any of below:
$123$123,123$1,123,123123,12312,123,12312312312123$12123123
I have written a Regex through which i can find the pattern needed --> ^\$?[0-9]{1,3}(?:(,[0-9]{3})*|([0-9]{3})*)?$ but I am not able to understand how to write substitute in order to format above examples to $XXX,XXX,XXX,XXX... format (as there are no fixed groups which I can pick).