-1

I have the following string:

Details
Cases
John
More

And I want to match 'John' and save it as a variable. For this I have the following regex that works on regex101.com:

/(?s)(?<=Cases).*?(?=More)/gm

However it throws а SyntaxError: Invalid regular expression: invalid group error

This is what my code looks like:

let reg = /(?s)(?<=Cases).*?(?=More)/gm

const extractedText = await pageSF.$eval('*', (el) => {
  const selection = window.getSelection();
  const range = document.createRange();
  range.selectNode(el);
  selection.removeAllRanges();
  selection.addRange(range);
  return window.getSelection().toString();
});
leadOwner = extractedText.match(reg);
console.log(leadOwner)

Thanks in advance!

Gregory
  • 9
  • 2

0 Answers0