CSharp examples for Language Basics:Regex
replace the word "stars" with "carets" and display the result
using System;/*from w ww. j a va 2s . c om*/ using System.Text.RegularExpressions; class MainClass { static void Main( string[] args ) { string testString1 = "This sentence ends in 5 stars *****"; Console.WriteLine( "First test string: {0}", testString1 ); // replace the word "stars" with "carets" and display the result testString1 = Regex.Replace( testString1, "stars", "carets" ); Console.WriteLine( "\"carets\" substituted for \"stars\": {0}", testString1 ); } }