FindReplaceOptions class

FindReplaceOptions class

Specifies options for find/replace operations. To learn more, visit the Find and Replace documentation article.

Constructors

NameDescription
FindReplaceOptions()Initializes a new instance of the FindReplaceOptions class with default settings.
FindReplaceOptions(direction)Initializes a new instance of the FindReplaceOptions class with the specified direction.
FindReplaceOptions(replacing_callback)Initializes a new instance of the FindReplaceOptions class with the specified replacing callback.
FindReplaceOptions(direction, replacing_callback)Initializes a new instance of the FindReplaceOptions class with the specified direction and replacing callback.

Properties

NameDescription
apply_fontText formatting applied to new content.
apply_paragraph_formatParagraph formatting applied to new content.
directionSelects direction for replace. Default value is FindReplaceDirection.FORWARD.
find_whole_words_onlyTrue indicates the oldValue must be a standalone word.
ignore_deletedGets or sets a boolean value indicating either to ignore text inside delete revisions. The default value is False.
ignore_field_codesGets or sets a boolean value indicating either to ignore text inside field codes. The default value is False.
ignore_fieldsGets or sets a boolean value indicating either to ignore text inside fields. The default value is False.
ignore_footnotesGets or sets a boolean value indicating either to ignore footnotes. The default value is False.
ignore_insertedGets or sets a boolean value indicating either to ignore text inside insert revisions. The default value is False.
ignore_shapesGets or sets a boolean value indicating either to ignore shapes within a text.
ignore_structured_document_tagsGets or sets a boolean value indicating either to ignore content of StructuredDocumentTag. The default value is False.
legacy_modeGets or sets a boolean value indicating that old find/replace algorithm is used.
match_caseTrue indicates case-sensitive comparison, false indicates case-insensitive comparison.
replacement_formatSpecifies format of the replacement. Default is ReplacementFormat.TEXT.
replacing_callbackThe user-defined method which is called before every replace occurrence.
smart_paragraph_break_replacementGets or sets a boolean value indicating either it is allowed to replace paragraph break when there is no next sibling paragraph.
use_legacy_orderTrue indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is False.
use_substitutionsGets or sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is False.

Examples

Shows how to toggle case sensitivity when performing a find-and-replace operation.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
builder.writeln('Ruby bought a ruby necklace.')
# We can use a "FindReplaceOptions" object to modify the find-and-replace process.
options = aw.replacing.FindReplaceOptions()
# Set the "match_case" flag to "True" to apply case sensitivity while finding strings to replace.
# Set the "match_case" flag to "False" to ignore character case while searching for text to replace.
options.match_case = match_case
doc.range.replace('Ruby', 'Jade', options)
self.assertEqual('Jade bought a ruby necklace.' if match_case else 'Jade bought a Jade necklace.', doc.get_text().strip())

Shows how to toggle standalone word-only find-and-replace operations.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
builder.writeln('Jackson will meet you in Jacksonville.')
# We can use a "FindReplaceOptions" object to modify the find-and-replace process.
options = aw.replacing.FindReplaceOptions()
# Set the "find_whole_words_only" flag to "True" to replace the found text if it is not a part of another word.
# Set the "find_whole_words_only" flag to "False" to replace all text regardless of its surroundings.
options.find_whole_words_only = find_whole_words_only
doc.range.replace('Jackson', 'Louis', options)
self.assertEqual('Louis will meet you in Jacksonville.' if find_whole_words_only else 'Louis will meet you in Louisville.', doc.get_text().strip())

See Also