I am using the Word JavaScript API to search for text, and I am using ‘r’ to represent new lines. This works correctly in the Word desktop app, but in Word Online, ‘r’ doesn’t seem to function properly for line or paragraph breaks during the search. Does anyone know how I can resolve this issue and ensure the search works consistently across both platforms?
await Word.run(async (context) => {
const improvementText = "process dependentrupon the submission".trim();
const body = context.document.body;
searchResults = body.search(improvementText, { matchCase: false, matchWholeWord: false, ignoreSpace: true, ignorePunct: true });
context.load(searchResults, 'items');
await context.sync();
searchResults.items.forEach(item => {
item.select();
item.font.highlightColor = "#FFD1DF";
highlightedChunks.push(improvementText);
});
});
How can I make this search work properly in Word Online?