
1arryb
User
Mar 16, 2009, 10:57 AM
Post #5 of 7
(12095 views)
|
Re: [devkpict] Escaping special characters from regular expressions
[In reply to]
|
Can't Post
|
|
Hi dev, 1. You might want to use an alternative regex delimiter since you are matching on strings containing the default '/', although you imply that your code compiles, so maybe that's irrelevant in this case:
if ($line =~ m|$_[0]|g ) ... 2. Of course m|/abc/pg| matches '/abc/pqrs', or anything else before or after. You'll have to make the pattern more specific to your data. Hints:
# Constrain match to the end of the line. m|$_[0]$| # Constrain match to the end of the word. m|$_[0]\s+| # Constrain match to a trailing character delimiter, like another slash. m|$_[0]/| etc. Cheers, Larry
|