5
I have a string with the characters "R$ 1,000.60" and would like to extract only the characters "1,000.60".
I tried using regular expression, but I couldn’t reach my goal. I got to this:
string valor = "";
string texto = "R$ 1.000,60";
Regex r = new Regex(@"^[0-9]*(?:\.[0-9]*)?$");
foreach (Match m in r.Matches(texto))
valor += m.Value;
Would anyone know how to solve this problem using regular expression or other technique?
+1 including by the goodwill of Edit :) We already have a good solution with Regex, and more alternatives may arise for you, the same Gypsy and/or other users.
– Bacco
A split wouldn’t be enough?
– touchmx
It is guaranteed that the format is always starting with
R$
and then comes the number that matters in the format shown?– Maniero
The values will not always start with R$, and you can also change the field orders, for example 50R$
– cumpadi