Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SubDocument.StartSearch(Regex, DocumentRange) Method

Provides a search interface for a search in the specified range using a regular expression pattern.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

#Declaration

IRegexSearchResult StartSearch(
    Regex regex,
    DocumentRange range
)

#Parameters

Name Type Description
regex Regex

A Regex object representing a search pattern.

range DocumentRange

A DocumentRange object representing a range to search.

#Returns

Type Description
IRegexSearchResult

An IRegexSearchResult interface used to perform a search.

#Remarks

The following code snippet illustrates the use of the StartSearch method, to perform searching for the date in US format. Note the use of named captures in the Regular Expression pattern.

The following code illustrates how to find and parse dates in US format using Regular Expression pattern matching:

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