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
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.
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 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))
Related GitHub Examples
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.