Why use look ahead and behinds given smart quotes make begin and end directional?
Have you tried something simpler like:
“[^”]*\s(were)[,;!?.\s][^“”]*”
So it looks for a starting quote, then any number of things that are not an ending quote followed by a space then the word in question followed by either a space or punctuation marks, then followed by any number of things that are not a beginning or ending quote, and then finally an ending quote.
Give a version of that a try.
We use this approach when using regex to find the next opening or closing tag by replacing the smart quotes with < and >
Last edited by KevinH; 01-22-2025 at 09:45 AM.
|