Get Started
Documentation

SearchAndReplace

SearchAndReplace(oProperties, oProperties.searchString, oProperties.replaceString, [oProperties.matchCase])

Find and replace text.

Parameters:

Name Type Default Description
oProperties Object

The properties for find and replace.

oProperties.searchString string

Search string.

oProperties.replaceString string

Replacement string.

oProperties.matchCase string true

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is the first sample text. The serial number of this sample text was replaced here.");
oDocument.SearchAndReplace({"searchString": "first", "replaceString": "second"});
builder.SaveFile("docx", "SearchAndReplace.docx");
builder.CloseFile();

Resulting document