I am trying to build a regular expression in Javascript that matches numbers with , and . as delimiters of thousands and decimals and vice versa. It must match 1,000,000.00 and 1.000.000,00. So far I have this:
/^(\d{1,3}(?:([,\.])\d{3}){1}(?:\2\d{3})*|\d+)(?:(?!\2)[,\.](\d*))?$/
but it does not match when the number does not have thousands delimitir and have decimals delimitir such as 100.00 or 100,00 for example. I think it's because the capturing group of the thousands delimiter is null.
Is it possible to build such regular expression?