There's more than one way to do things | |
PerlMonks |
strings contain regular expression charactersby onegative (Scribe) |
on May 24, 2009 at 16:56 UTC ( [id://765936]=perlquestion: print w/replies, xml ) | Need Help?? |
onegative has asked for the wisdom of the Perl Monks concerning the following question:
G'day Monks,
I am trying to figure out how to accept a string which contains regular expression characters as part of the string's value but do not represent regEx functionality to grep that string out of another array with the perl grep function but to escape it as a literal character??? string examples: string = DB2$PB string = SYSA$ So I am extracting this string from one array and then trying to use perl's grep to verify its existence in another array. The problem is that I am not sure how I can convert the extracted string's special characters to have an escape in front of them? I tried using substitution but again the $ is being read as a regEx character. Any help would be greatly appreciated. Thanks, Danny
Back to
Seekers of Perl Wisdom
|
|