Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

SubDocument.ReplaceAll(String, String, SearchOptions) Method

Finds all occurrences of the search string in the current document, and replaces them with the replacement string.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v19.1.Core.dll

Declaration

int ReplaceAll(
    string textToFind,
    string replaceWith,
    SearchOptions options
)

Parameters

Name Type Description
textToFind String

A string specifying the search text.

replaceWith String

A string specifying the replacement text.

options SearchOptions

A SearchOptions enumeration specifying search options.

Returns

Type Description
Int32

The number of replacements made.

Example

The following code snippet illustrates how the SubDocument.ReplaceAll method with Regular Expressions can be used to convert all US formatted dates (month/day/year) in the document to two European formats: year-month-day and day.month.year.

document.AppendText("12\14\2014" & Environment.NewLine)
Dim pattern As String = "(?<mm>\d{2}).(?<dd>\d{2}).(?<yyyy>\d{4})"
Dim replacementString As String = "${yyyy}-${mm}-${dd} or ${dd}.${mm}.${yyyy}"
Dim myRegEx As New System.Text.RegularExpressions.Regex(pattern)
Dim count As Integer = document.ReplaceAll(myRegEx, replacementString)
System.Windows.Forms.MessageBox.Show(String.Format("We've done {0} replacement(s).", count))

The following code snippets (auto-collected from DevExpress Examples) contain references to the ReplaceAll(String, String, SearchOptions) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also