反转字符串中的任何数字组

joz*_*ozi 4 c# string reverse

例如,我需要反转文本中的所有数字组

"test text 145 for 23 site 1"
Run Code Online (Sandbox Code Playgroud)

我们需要这个输出

"test text 541 fro 32 site 1"
Run Code Online (Sandbox Code Playgroud)

hta*_*deh 8

C#反转字符串中的所有数字?

感谢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.
Run Code Online (Sandbox Code Playgroud)