- class Program
- {
- // 如何把用户输入字符串里面的数字挑选出来?
- //asp.net20140120
- static void Main(string[] args)
- {
-
- string str = "asp.net20140120";
- //string str1 = "asp123.net20140120mmtk";
- string regex = @"[0-9]+";
- MatchCollection mc = Regex.Matches(str, regex);
- //MatchCollection mc = Regex.Matches(str1, regex);
- foreach (Match m in mc)
- {
- Console.WriteLine(m.Value);
- }
- Console.ReadKey();
- }
复制代码
|