⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex-10-07

📁 Programming Csharp Source Code(代码) Programming Csharp Source Code
💻
字号:
// Example 10-07: Using MatchCollection and Match

namespace Programming_CSharp
{
   using System;
   using System.Text.RegularExpressions;

   class Test
   {
      public static void Main()
      {
         string string1 = "This is a test string";
            
         // find any nonwhitespace followed by whitespace
         Regex theReg = new Regex(@"(\S+)\s");
        
         // get the collection of matches
         MatchCollection theMatches = 
            theReg.Matches(string1);

         // iterate through the collection
         foreach (Match theMatch in theMatches)
         {
            Console.WriteLine(
               "theMatch.Length: {0}", theMatch.Length);

            if (theMatch.Length != 0)               
            {
               Console.WriteLine("theMatch: {0}", 
                  theMatch.ToString());              
            }       
         }           
      }               
   }                   
}             


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -