SearchAndReplace

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

Finds and replaces the text.

Parameters:

Name Type Default Description
oProperties Object

The properties to find and replace.

oProperties.searchString string

Search string.

oProperties.replaceString string

Replacement string.

oProperties.matchCase string true

Case sensitive or not.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var 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