How does C # match words that begin with S
This article mainly explains "how C # matches words that begin with S". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to match words that begin with S".
Example
The following example matches a word that starts with'S':
Example
Using System
Using System.Text.RegularExpressions
Namespace RegExApplication
{
Class Program
{
Private static void showMatch (string text, string expr)
{
Console.WriteLine ("The Expression:" + expr)
MatchCollection mc = Regex.Matches (text, expr)
Foreach (Match m in mc)
{
Console.WriteLine (m)
}
}
Static void Main (string [] args)
{
String str = "A Thousand Splendid Suns"
Console.WriteLine ("Matching words that start with'slots:")
ShowMatch (str, @ "\ bS\ S*")
Console.ReadKey ()
}
}
}
When the above code is compiled and executed, it produces the following results:
Matching words that start with 'S':The Expression:\ bS\ S*SplendidSuns so far, I believe you have a better understanding of "how C # matches words that begin with S". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!