in reply to How to identify invalid reg. expr.?
something like "***" entered will raise some flags, as "*" is a quantifier, and must follow something other than another quantifier. A single left paren or an "unclosed" character class (a missing right bracket) will also do it. I'm sure there are other regexen that will "break" this.my $searchstring = $obj->param('words'); eval { no warnings; "" =~ /$searchstring/}; if ($@) { ... }
I should point out that I got the idea for using that method from here somewhere, but I can't find the node in question. I also don't know the ins and outs of eval (block vs. string, for example), but this solution works for me. YMMV. HTH.
--
There are 10 kinds of people -- those that understand binary, and those that don't.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: How to identify invalid reg. expr.?
by samtregar (Abbot) on Jun 05, 2002 at 18:40 UTC | |
by merlyn (Sage) on Jun 05, 2002 at 20:10 UTC | |
by mephit (Scribe) on Jun 05, 2002 at 20:50 UTC | |
by merlyn (Sage) on Jun 05, 2002 at 20:59 UTC | |
by samtregar (Abbot) on Jun 05, 2002 at 20:14 UTC | |
by mephit (Scribe) on Jun 05, 2002 at 19:55 UTC | |
by samtregar (Abbot) on Jun 05, 2002 at 20:11 UTC | |
by Smylers (Pilgrim) on Jun 06, 2002 at 12:13 UTC | |
by mephit (Scribe) on Jun 06, 2002 at 19:44 UTC |