开发者

How to use C# Regular Expression to get the match number list?

string inputText = "abc13500008888,   *a1c13688886666abc   mm13565685555**" ;
开发者_StackOverflow中文版

How to use C# Regular Expression to get the match number list?

The rule is that is a 11 continuous number and the first letter is 1.

The results should be:

13500008888
13688886666
13565685555


If the numbers are always 11 digits starting with 1, you can just do

Regex.Matches(inputText, @"1\d{10}");

If you want to match other lengths as well, you can either use + for one or more or {min,} where min is the minimum number of digits you want to match.


Regex.Matches(input, @"\d+");


Regex.Matches(input, @"1\d{10}"); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜