System.Text.RegularExpressions.Regex.Match C# (CSharp) Method

Match() public method

public Match ( string input ) : System.Text.RegularExpressions.Match
input string
return System.Text.RegularExpressions.Match
        public System.Text.RegularExpressions.Match Match(string input)
        {
            throw null;
        }

Same methods

Regex::Match ( string input, int startat ) : System.Text.RegularExpressions.Match
Regex::Match ( string input, int beginning, int length ) : System.Text.RegularExpressions.Match
Regex::Match ( string input, string pattern ) : System.Text.RegularExpressions.Match
Regex::Match ( string input, string pattern, System options ) : System.Text.RegularExpressions.Match
Regex::Match ( string input, string pattern, System options, System matchTimeout ) : System.Text.RegularExpressions.Match

Usage Example

Esempio n. 1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string strPattern = @"CM-\w+";

            string strToTest = "CM-2345 implemented";
            string strToTest2 = "Changes in CM-2395";
            string strToTest3 = "Changes for CM-2365 complete and need to change CM-1258 ";
            var regEx = new Regex(strPattern);

            var match1 = regEx.Match(strToTest);

            MessageBox.Show(match1.Success ? match1.Groups[0].Value : "not match " + strToTest);

            var match2 = regEx.Match(strToTest2);
            MessageBox.Show(match2.Success ? match2.Groups[0].Value : "not match " + strToTest2);

            var matches3 = regEx.Matches(strToTest3);
            foreach (Match match3 in matches3)
            {
                foreach (Capture capt in match3.Captures    )
                {
                    MessageBox.Show(string.Format("Index={0}, Value={1}", capt.Index, capt.Value));
                }
            }

            //MessageBox.Show(match3.Success ? match3.Groups[0].Value : "not match " + strToTest3);
            //MessageBox.Show(match3.Success ? match3.Groups[1].Value : "not match " + strToTest3);
        }
All Usage Examples Of System.Text.RegularExpressions.Regex::Match