SearchAndReplace

function SearchAndReplace(
  oProperties: object = null,
  oProperties.searchString: string = null,
  oProperties.replaceString: string = null,
  oProperties.matchCase: string = true,
): void

Description

Finds and replaces the text.

Parameters

oPropertiesobjectdefault: null

The properties to find and replace.

oProperties.searchStringstringdefault: null

Search string.

oProperties.replaceStringstringdefault: null

Replacement string.

oProperties.matchCasestringdefault: true

Case sensitive or not.

Returns

void

Try It

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"});

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).