geekondemand has asked for the wisdom of the Perl Monks concerning the following question:
my $regex = qr(/.../); # ... implies put any pattern here
Can I compile with qr another regex $notregex that is true if and only if $regex is false?
I know I can use $regex with !~ to get this effect, but I situations where it would be more elegant to simply pass in the new regex.
Now, supposing that this is possible. Could one write a subroutine that takes one regex as input and returns the "does not match" regex as output?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Negation/Complement of a Regex
by moritz (Cardinal) on May 22, 2008 at 16:36 UTC | |
|
Re: Negation/Complement of a Regex
by almut (Canon) on May 22, 2008 at 17:18 UTC | |
|
Re: Negation/Complement of a Regex
by samtregar (Abbot) on May 22, 2008 at 21:38 UTC | |
|
Re: Negation/Complement of a Regex
by gloryhack (Deacon) on May 23, 2008 at 07:44 UTC |