Test whether the regular expression pattern matches the string. - CSharp System

CSharp examples for System:String Match

Description

Test whether the regular expression pattern matches the string.

Demo Code

// BDHero is free software: you can redistribute it and/or modify
using System.Threading;
using System.Text.RegularExpressions;
using System.Net;
using System.Collections.Generic;
using System;//from www  .java  2  s . c o  m

public class Main{
        /// <summary>
        /// Test whether the regular expression pattern matches the string.
        /// </summary>
        /// <param name="input">
        /// The string to test
        /// </param>
        /// <param name="pattern">
        /// The pattern
        /// </param>
        /// <returns>
        /// true if the pattern matches, false if not.
        /// </returns>
        public static bool RegexTest(this String input, string pattern)
        {
            return Regex.IsMatch(input, pattern);
        }
}

Related Tutorials