Dan*_*npe 4 .net c# regex string
我有一个字符串:
" 你好7866592这是我的12432字符串和823我需要翻转所有123 "
我想成为
" 你好2956687这是我的23421字符串和328我需要翻转所有321 "
我使用这个正则表达式来获取所有数字:
Regex nums = new Regex("\d+");
Run Code Online (Sandbox Code Playgroud)
Yur*_*ich 17
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)
| 归档时间: |
|
| 查看次数: |
1527 次 |
| 最近记录: |