First, avoid using $a and $b; they're special.
If you are intending for $regexPattern to be a user supplied regex that may contain errors, then perhaps you want to *eval* the regex match and trap said errors.
my $matched; my $contender = 'foo'; my $regexPattern = '+foo'; #won't work eval { $matched = $contender =~ /$regexPattern/ }; warn $@ if $@; print "Hey, did I survive the error? Yay!\n";
In reply to Re: special characters in regexp
by SuicideJunkie
in thread special characters in regexp
by moked
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |