View Single Post
Old 01-22-2025, 08:46 AM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,588
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by ElMiko View Post
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...
Lookaheads don't require a defined width. Neither in the built-in re module, nor in the Barnett regex module included with Sigil's bundled python. The Barnett regex module also has the added advantage of allowing variable width lookbehinds as well. Just use "import regex as re" to work with existing code.

But you're right that the built-in re module does not allow variable-width lookbehinds.

Last edited by DiapDealer; 01-22-2025 at 08:49 AM.
DiapDealer is offline   Reply With Quote