这里在写这一篇实例的时候提出了要匹配一段字符串中的数字,匹配第一次出现的内容 和 匹配所有的内容
String text = "Hello 23 Boy 24!";
Regex regex = new Regex("[0-9]+");
Match match = regex.Match(text);
System.Console.WriteLine(match.Value.ToString());
MatchCollection matches = regex.Matches(text);
foreach(Match xmatch in matches){
System.Console.WriteLine(xmatch.Value.ToString());
}
本文介绍如何使用正则表达式在C#中匹配字符串内的数字。通过具体代码示例展示了如何获取第一次出现的数字及所有出现的数字。
701

被折叠的 条评论
为什么被折叠?



