Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Expression régulière: Utilisation avec la méthode ‘split’ et forEach


{filelink=18805}

 using System;
 using System.Text;
 using System.Text.RegularExpressions;
 
namespace ExpressionReguliere
 {
    public class ExempleExpressionReguliere
    {
       public void Run()
       {
           string sRegex = "Lundi,Mardi, phyton.MesExemples.com, 2011";
           Regex regex = new Regex(" |, |,");
           StringBuilder sBuilder = new StringBuilder();
           int id = 1;
 
           foreach (string sousChaine in regex.Split(sRegex))
           {
               sBuilder.AppendFormat( "{0}: {1} ", id++, sousChaine);
           }
           Console.WriteLine("{0}", sBuilder);
       }
 
       [STAThread]
       static void Main()
       {
          ExempleExpressionReguliere t = new ExempleExpressionReguliere();
          t.Run();
       }
    }
 }

No comments yet.

Leave a Comment