IRegexSearchResult Interface
Defines the interface used for text searching, using regular expressions.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v19.1.Core.dll
Declaration
Remarks
The SubDocument.StartSearch method provides the IRegexSearchResult interface. You can then use the Match interface to get the match, continue searching or perform the replacement.
The following code illustrates the use of the IRegexSearchResult interface obtained via the SubDocument.StartSearch method to find and parse dates in US format:
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-richedit-document-api-e5219
document.AppendText("12\14\2014" & Environment.NewLine)
Dim result As IRegexSearchResult
Dim pattern As String = "(?<mm>\d{2}).(?<dd>\d{2}).(?<yyyy>\d{4})"
Dim myRegEx As New System.Text.RegularExpressions.Regex(pattern)
result = document.StartSearch(myRegEx)
If result.FindNext() Then
Dim dayFound As String = result.Match.Groups(2).Value
Dim monthFound As String = result.Match.Groups(1).Value
Dim yearFound As String = 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))
End If
Example
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-richedit-document-api-e5219
document.AppendText("12\14\2014" & Environment.NewLine)
Dim result As IRegexSearchResult
Dim pattern As String = "(?<mm>\d{2}).(?<dd>\d{2}).(?<yyyy>\d{4})"
Dim myRegEx As New System.Text.RegularExpressions.Regex(pattern)
result = document.StartSearch(myRegEx)
If result.FindNext() Then
Dim dayFound As String = result.Match.Groups(2).Value
Dim monthFound As String = result.Match.Groups(1).Value
Dim yearFound As String = 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))
End If
See Also