I need a Regex for numbers that considers thousands and decimal places. The one I came up so far is:
\d{1,3}(\.\d{3})*(,\d*)?
It will catch 3.000,00 as well as 3,00 and 3.000. Sweet.
The problem is that I need it to be very greedy, and capture larger numbers first, for instance, for this input:
125,45.124.890,45,32,67.456
I’d need it to capture 45.124.890,45 as a number. It’s important to me because it’s the biggest one. My regex just won’t work, because it will capture 123,45 and then 45 will not be considered for the next match. So the next number it captures is 124.890,45 which is not good for me.
Any thoughts?
PS As I’m brazillian the separators are inverted
Use regex pattern
C# demo:
Output:
Test this demo here.