Sunday, 3 December 2017

C# Program to Illustrate Regular Expression Pattern


Code:

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 = "Executecodes , a high end Technology Training company";
            Console.WriteLine("Matching words that start with 'S': ");
            showMatch(str, @"\bS\S*");
            Console.ReadKey();
        }
    }
}


Output:

Matching Words that Starts With 'Executecodes' : 
The Expression : \bs\s*
Executecodes


More C# Programs:


















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...