Blackthorn

Match / NextMatch

Nov 6th, 2014
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace StringMagic
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string longString = "<span>1</span><span>2</span><span>3</span>";
  15.             Regex pattern = new Regex(@">(\d)<");
  16.  
  17.             var match = pattern.Match(longString);
  18.             while (match.Value != "")
  19.             {
  20.                 Console.WriteLine(match.Groups[1]);
  21.                 match = match.NextMatch();
  22.             }
  23.             Console.ReadKey();
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment