Do a replace using the Regex : Regular Expression : Regular Expression C# Examples


C# Examples » Regular Expression » Regular Expression »

 

Do a replace using the Regex









    
using  System;
using  System.Text.RegularExpressions;

public  class  MainClass
{
        static  void  Main(  string[]  args  )  {
                //  Create  regex  to  search  for  IP  address  pattern.
                string  pattern  =  @"([01]?\d\d?|2[0-4]\d|25[0-5])\."  +
                                                  @"([01]?\d\d?|2[0-4]\d|25[0-5])\."  +
                                                  @"([01]?\d\d?|2[0-4]\d|25[0-5])\."  +
                                                  @"([01]?\d\d?|2[0-4]\d|25[0-5])";
                Regex  regex  =  new  Regex(  pattern  );
                Console.WriteLine(  "Input  given  -->  {0}",
                                                      regex.Replace("192.168.199.1",
                                                                                  "xxx.xxx.xxx.xxx")  );
        }
}
    
   
  
   



Output

Input given --> xxx.xxx.xxx.xxx


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Regular Expression
» Regular Expression