View Single Post
Old 01-22-2025, 07:03 AM   #1
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
[RegEx] How to match a string occurring somewhere between quotation marks

I am trying to find a word, but only when it occurs between quotation marks. For example, I want to find the word "were", but only when it occurs in dialogue (the punctuation has been smartened, by the way). As in:

Code:
“That’s where were going!”
Normally I'd try to use a combination of lookaheads and lookbehinds to find it, as in:

Code:
(?<=“.*?)\bwere\b(?=.*?”)
But because lookaheads/lookbehinds need a defined character length (I think), the above won't actually work...

Is there a way to match *and* isolate the "were"? Or is matching the whole dialogue string the best one can hope for (eg: “.*?\bwere\b.*?”)?

Last edited by ElMiko; 01-22-2025 at 07:18 AM.
ElMiko is offline   Reply With Quote