Seeing as how (?i) IS a global flag, I'm fairly certain it should be the very first thing. I've not done any real testing, but I'm guessing the plugin has simply been lucky in that it ran OK with earlier versions of Sigil's bundled Python (when this particular scenario was in play for the epub).
EDIT:
It looks like this can be fixed as simply as by using the bundled regex module instead of the built-in re.
Changing:
import re
to:
import regex as re
Makes your test case from above work regardless of where the flags are placed.
EDIT 2:
It's my opinion that the Barnett regex module continues to be more robust than the built-in re module. That's why I included it in the bundled Sigil python from the beginning and tried to encourage its use in plugins.
Last edited by DiapDealer; 12-11-2024 at 01:17 PM.
|