Use regular to replace strings : Regular Expression : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Regular Expression »

 

Use regular to replace strings









    


using System;
using System.Text.RegularExpressions;

class RegexSubstitution
{
   public static void Main()
   {
      string testString1 = " stars *****";
      Regex testRegex1 = new Regex( @"\d" );

      Console.WriteLine( "Original string: " + testString1 );
      testString1 = Regex.Replace( testString1, "stars", "carets" );
      Console.WriteLine( "\"carets\" substituted for \"stars\": " + testString1 );
      
   }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Regular Expression