|RegExp to match against RegExp's firstname.lastname@example.org (whiskey) (2007-03-01)|
|Re: RegExp to match against RegExp's JoelCSalomon@Gmail.com (Joel C. Salomon) (2007-03-03)|
|Re: RegExp to match against RegExp's email@example.com (Russ Cox) (2007-03-05)|
|Re: RegExp to match against RegExp's firstname.lastname@example.org (Thomas Dickey) (2007-03-08)|
|Re: RegExp to match against RegExp's email@example.com (whiskey) (2007-03-14)|
|From:||"Russ Cox" <firstname.lastname@example.org>|
|Date:||5 Mar 2007 03:12:29 -0500|
|Posted-Date:||05 Mar 2007 03:12:29 EST|
If all you want to do is match something between slashes, regardless
of whether it is a well-formed regular expression, you could, ignoring
escaping issues, use "/([^/\]|\.)*/", which matches a sequence of
non-slash characters or escape sequences between slashes. Escaping
that in the usual way gets you to the less readable $s =~
/\/([^\/\\]|\\.)*\//. The same trick is useful for extracting quoted
strings from, say, C programs -- just change the / to " in the
Verifying that something between slashes is a well-formed regular
expression is another problem, one that is not best approached using
regular expressions, even in languages like Perl where the so-called
regular expressions have been beefed up enough to make it possible.
Determining, for a given place in a Perl program text, whether a slash
begins a regular expression or is just a division operator, is yet
another problem, again not really something you'd want to solve with
regular expressions, though a few heuristics (like does it follow a
"~") would probably get you close enough.
The short answer is do something that works for your program or learn
how to make Perl just dump the regular expressions out of the source
program for you (I recall there being a Perl module or an option or
some way to do that). There is no clean solution.
Return to the
Search the comp.compilers archives again.