You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
801 B
C#

/*
* C# Program to Illustrate Regular Expression Pattern
*/
using System;
using System.Text.RegularExpressions;
namespace Application
{
class Program
{
private static void showMatch(string text, string expr)
{
Console.WriteLine("The Expression : " + expr);
MatchCollection m = Regex.Matches(text, expr);
foreach (Match m1 in m)
{
Console.WriteLine(m1);
}
}
static void Main(string[] args)
{
string str = "Sanfoundry , a high end Technology Training company";
Console.WriteLine("Matching words that start with 'S': ");
showMatch(str, @"\bS\S*");
Console.ReadKey();
}
}
}
/*
Matching Words that Starts With 'S' :
The Expression : \bs\s*
Sanfoundry