.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

IRegexSearchResult.Match Property

Provides access to the results from a single regular expression match.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v20.2.Core.dll

Declaration

Match Match { get; }
ReadOnly Property Match As Match

Property Value

Type Description
Match

An object exposing the Match interface, containing information about the match.

Remarks

This property can be used to obtain a substring in the document that matches the regular expression pattern. If the pattern contains groupings, you can use the Match.Groups property to get them for a current match.

Examples

This code snippet uses Regular Expressions to find a date in US format within the document text and parse it.

document.AppendText("12\\14\\2014" + Environment.NewLine);
IRegexSearchResult result;
string pattern = @"(?<mm>\d{2}).(?<dd>\d{2}).(?<yyyy>\d{4})";
System.Text.RegularExpressions.Regex myRegEx = 
    new System.Text.RegularExpressions.Regex(pattern);

result = document.StartSearch(myRegEx);
if (result.FindNext())
{
    string dayFound = result.Match.Groups[2].Value;
    string monthFound = result.Match.Groups[1].Value;
    string yearFound = result.Match.Groups[3].Value;
    document.AppendText(String.Format("Found a date that is the {0} day of the {1} month of the {2} year.",
        dayFound, monthFound, yearFound));
}
See Also