stefan k has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks,
it has already been hard enough to find a good title for this question and even harder for me to find the solution to this problem (which -I am sure- must be very plain and simple, because I am looking for it so long(*))
it has already been hard enough to find a good title for this question and even harder for me to find the solution to this problem (which -I am sure- must be very plain and simple, because I am looking for it so long(*))
I am building a regexp dynamically, say
(using a look behind just to make it a little more spicy) where $a and $b will always contain exactly one char, but that char might be special in regexps. For example $a can be "?" or "-" depending on the current situation.$re = qr(/($<!$a)$b/);
The question is: is there any way (a module at CPAN which I have overlooked or an operator I didn't fully understand or ...) to dynamically escape those w/o me going through a list of special chars and checking them?
Footnotes:
(*) A simple rule of programming: the longer you search (for an error, for a solution, for the correct way, ...) the plainer is the answer (read as: the more stupid was the error, the simpler is the solution, the cleaner is the correct way ...) ;-)
Regards... | Stefan |
you begin bashing the string with a +42 regexp of confusion |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Maybe Escape in Dynamic RegExps
by saintmike (Vicar) on Apr 30, 2004 at 08:18 UTC | |
Re: Maybe Escape in Dynamic RegExps
by gellyfish (Monsignor) on Apr 30, 2004 at 08:19 UTC | |
Re: Maybe Escape in Dynamic RegExps
by Zaxo (Archbishop) on Apr 30, 2004 at 08:27 UTC | |
Re: Maybe Escape in Dynamic RegExps
by halley (Prior) on May 02, 2004 at 14:10 UTC | |
Re: Maybe Escape in Dynamic RegExps
by stefan k (Curate) on Apr 30, 2004 at 10:49 UTC |
Back to
Seekers of Perl Wisdom