Match words that contain the pattern 'ai'
using System;
using System.Text.RegularExpressions;
class MainClass {
private static void DisplayMatches(string text,string regularExpressionString) {
Console.WriteLine("using the following regular expression: " +regularExpressionString);
MatchCollection myMatchCollection = Regex.Matches(text, regularExpressionString);
foreach (Match myMatch in myMatchCollection) {
Console.WriteLine(myMatch);
}
}
public static void Main() {
string text ="put curtain pertain perday";
Console.WriteLine("Matching words that contain the pattern 'ai'");
DisplayMatches(text, @"\S*(ai)\S*");
}
}
Output Matching words that contain the pattern 'ai'
using the following regular expression: \S*(ai)\S*
curtain
pertain
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
-
-
-
|