We don't bite newbies here... much | |
PerlMonks |
safe regex variablesby oconnelm (Initiate) |
on Jul 06, 2001 at 01:34 UTC ( [id://94293]=perlquestion: print w/replies, xml ) | Need Help?? |
oconnelm has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have a pretty ugly text-processing question. I'm trying to match a string denoted as a boundary by MIME headers then use it as a variable to annotate the different sections of a multipart message. This would be fine, except for the fact that the boundary strings conatin lots of regular expression quantifiers and tend to look like
I tried backslashing the variable name for the boundary string like:
but this never matched the following instances, although it did let me use the string without a bad regex error. Just for kicks, I also tried using a backslash on the input, since it has the same problematic characters, but it doesn't get evaluated as a regular expression, so that unsurprisingly had no effect. My question then is "Is there a way to safely (and efectively) use strings that contain special regex characters as patterns to be matched, without knowing ahead of time when, where and which special characters will occur in the pattern?" Thanks, Mike O'Connell
Back to
Seekers of Perl Wisdom
|
|