I need reverse all group of digit in text for example
"test text 145 for 23 site 1"
we need this output
"test text 541 fro 32 site 1"
C# Reverse all numbers in string?
Thanks to Yuriy Faktorovich
var replacedString =
Regex.Replace(//finds all matches and replaces them
myString, //string we're working with
@"\d+", //the regular expression to match to do a replace
m => new string(m.Value.Reverse().ToArray())); //a Lambda expression which
//is cast to the MatchEvaluator delegate, so once the match is found, it
//is replaced with the output of this method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With