Back to Devexpress

SubDocument.FindAll(Regex, DocumentRange) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-subdocument-dot-findall-x28-system-dot-text-dot-regularexpressions-dot-regex-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentrange-x29.md

latest3.1 KB
Original Source

SubDocument.FindAll(Regex, DocumentRange) Method

Finds all occurrences of a character pattern specified by the regular expression.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
DocumentRange[] FindAll(
    Regex regex,
    DocumentRange range
)
vb
Function FindAll(
    regex As Regex,
    range As DocumentRange
) As DocumentRange()

Parameters

NameTypeDescription
regexRegex

A Regex object representing a regular expression to search.

| | range | DocumentRange |

A DocumentRange instance representing a document range to search.

|

Returns

TypeDescription
DocumentRange[]

An array of DocumentRange objects representing ranges in the document matching the specified pattern.

|

Remarks

The default maximum length of a string that can be obtained in a regular expression search is 128 characters. Use the DocumentSearchOptions.RegExResultMaxGuaranteedLength property to change the maximum string length.

This code snippet finds all numbers enclosed in square brackets within the first paragraph.

csharp
using DevExpress.XtraRichEdit.API.Native;
using System.Text.RegularExpressions;
// ...
Regex expr = new Regex("\\[[0-9]+\\]");
Paragraph firstParagraph = wordProcessor.Document.Paragraphs[0];
DocumentRange[] found = wordProcessor.Document.FindAll(expr, firstParagraph.Range);
vb
Imports DevExpress.XtraRichEdit.API.Native
Imports System.Text.RegularExpressions
' ...
Dim expr As Regex = New Regex("\[[0-9]+\]")
Dim firstParagraph As Paragraph = wordProcessor.Document.Paragraphs(0)
Dim found As DocumentRange() = wordProcessor.Document.FindAll(expr, firstParagraph.Range)

See Also

SubDocument Interface

SubDocument Members

DevExpress.XtraRichEdit.API.Native Namespace