Closed euantorano closed 8 months ago
This can be easily implemented without even touching the parsing. Just convert the flags into their string representation and prepend them to the regex.
The question is, you find this re(r"regex", {flagMultiLine})
easier to read than re"(?m)regex"
?
Note that both are compiled at compile-time, so flags can't be passed at runtime (although, there's a runtime version) in case someone would want that.
Yeah, I find names much more readable personally. Remembering that ?m
makes the regex multi-line becomes difficult when you use multiple languages (or it does for me at least).
Remembering that ?m makes the regex multi-line becomes difficult when you use multiple languages (or it does for me at least).
That should not be a problem with PCRE compatible regex engines. Even in JS the letters mean the same thing. However, I think I'll add this feature. If you have time to implement it yourself I'll gladly merge the PR.
The documentation suggests that currently flags are passed as characters in a string. In my opinion, it's much cleaner and easier to read to pass a
set[Flag]
whereFlag
is anenum
of possible flags to either the template to create the regex or the procs to execute a regex.Obviously this wouldn't work for per-group flags, but for full expression flags only.