Get the App
SLTechnology News&Howtos  ›  Development  › 

How does C # match words that begin with S

Shulou Source: shulou.com Published: 2022-06-01 01:52:26 10月02日 Update

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!

Tags: Words openings examples content facets learning practicality deeper code interests practicality practicality simplicity of operation methods more friends results websites channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux macOS OPPO Reno Shulou Information