IgnoreFields

FindReplaceOptions.IgnoreFields property

Gets or sets a boolean value indicating either to ignore text inside fields. The default value is false.

public bool IgnoreFields { get; set; }

Remarks

This option affects whole field (all nodes between FieldStart and FieldEnd).

To ignore only field codes, please use corresponding option IgnoreFieldCodes.

Examples

Shows how to ignore text inside fields.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Hello world!");
builder.InsertField("QUOTE", "Hello again!");

// We can use a "FindReplaceOptions" object to modify the find-and-replace process.
FindReplaceOptions options = new FindReplaceOptions();

// Set the "IgnoreFields" flag to "true" to get the find-and-replace
// operation to ignore text inside fields.
// Set the "IgnoreFields" flag to "false" to get the find-and-replace
// operation to also search for text inside fields.
options.IgnoreFields = ignoreTextInsideFields;

doc.Range.Replace("Hello", "Greetings", options);

Assert.AreEqual(
    ignoreTextInsideFields
        ? "Greetings world!\r\u0013QUOTE\u0014Hello again!\u0015"
        : "Greetings world!\r\u0013QUOTE\u0014Greetings again!\u0015", doc.GetText().Trim());

See Also