ReplaceCurrentSentence

function ReplaceCurrentSentence(
  sReplace: string = null,
  sPart: "undefined" | before | after = null,
): boolean

Description

Replace the current sentence or part of the current sentence with the specified text

Parameters

sReplacestringdefault: null

String to replace

sPart"undefined" | before | afterdefault: null

Specifies the desired part of the current sentence

Returns

boolean

Try It

let oDocument = Api.GetDocument();

let sText = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
let oPara1 = oDocument.GetElement(0);
oPara1.AddText(sText);

let oPara2 = Api.CreateParagraph();
oDocument.Push(oPara2);
let oRun = oPara2.AddText(sText);
oRun.MoveCursorToPos(80);
oDocument.ReplaceCurrentSentence("The quick brown fox jumps over the lazy dog.");


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).