I'm having trouble, replacing multi-lines text in a Google Doc, using App Script.
I've took the time to search and test similar questions I've learn a lot but I can't go through.
I have several blocs of text like below in my google Doc. I'm using tag labels to find what text bloc needs to be replaced. I replace the text block from "||TAG_LABEL" to "||"
||TAG_LABEL
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.||
From what I've learned I have to pass a string to replaceText.
I've checked the console and textToReplace is a string but the text is not replaced
function regexTestFunction(){
const document = DocumentApp.getActiveDocument();
const documentBody = document.getBody();
const keyWord = "TAG_LABEL";
const textToReplace = "\\|{2} (.*?)" + keyWord + "[\\s\\S]*?\\|{2}";
const deleteText = documentBody.replaceText(textToReplace,"");
}
Thank you for your help

