Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If the program that's calling the function is accepting a regex input by a user, requiring them to use '/^(?:(?!bar).)*$/s' when they want to find things that don't contain some word or phrase is not very friendly. If the input is simple text, you might get away with passing "/^(?:(?!$their_input).)*$/s", thus wrapping their input in the appropriate construct if they specified 'NOT bar' or '!bar', or some flag to indicate that they want to invert the sense of the comparison. You'd have to strip the flag from the input before calling the function. But if your going to have a flag they can use to indicate the inversion of the match, why not simply pass that flag through to the function and use it to determine the operator to use
That's the way grep -v works, which is a pretty good precedent. Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham"Think for yourself!" - Abigail Timing (and a little luck) are everything! In reply to Re: positive regex for inverted match
by BrowserUk
|
|