Is it possible to search and replace the first item found, just keep in mind that only the first item found will be replace. I’ve tried this one SearchAndReplace | ONLYOFFICE but it will replace all the items found that is not match my target.
Hello @ZangHoang,
Sorry for the late reply. This can be achieved the following way:
var doc = Api.GetDocument();
var search = doc.Search("text_to_search");
search[0].Select();
Api.ReplaceTextSmart(["text_to_replace"], "", "");
Methods used:
-
Search the required text
Search | ONLYOFFICE -
Select the first found item
Select | ONLYOFFICE -
Replace the selection with new text
ReplaceTextSmart | ONLYOFFICE