legacy_mode property
FindReplaceOptions.legacy_mode property
Gets or sets a boolean value indicating that old find/replace algorithm is used.
@property
def legacy_mode(self) -> bool:
...
@legacy_mode.setter
def legacy_mode(self, value: bool):
...
Remarks
Use this flag if you need exactly the same behavior as before advanced find/replace feature was introduced. Note that old algorithm does not support advanced features such as replace with breaks, apply formatting and so on.
Examples
Shows how to recognize and use substitutions within replacement patterns.
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
builder.write('Jason gave money to Paul.')
options = aw.replacing.FindReplaceOptions()
options.use_substitutions = True
# Using legacy mode does not support many advanced features, so we need to set it to 'False'.
options.legacy_mode = False
doc.range.replace_regex('([A-z]+) gave money to ([A-z]+)', '$2 took money from $1', options)
self.assertEqual(doc.get_text(), 'Paul took money from Jason.\x0c')
See Also
- module aspose.words.replacing
- class FindReplaceOptions