zemane has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to match a regular expression that may contain a special char that I want it to be ignored. For example, suppose I am looking for the pattern 'aabb' and anywhere in the string I could have the special char \xFF.
So my string could be any of these:
And I want the following code to match successfully:$str = "a\xFFabb"; $str = "aa\xFFbb"; $str = "aabb\xFF";
Is there any way to tell Perl to ignore a certain special character when looking for a match?if ($str =~ "aabb") { print "match found\n"; } else { print "no match\n"; }
I don't want to remove the special char from the string because later on I want to find this special char and use its position to insert other stuff into the string. So, this special char is used as a marker for future insertions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can I make Perl ignore a special char when matching?
by GrandFather (Saint) on Jul 23, 2008 at 22:49 UTC | |
|
Re: Can I make Perl ignore a special char when matching?
by aquarium (Curate) on Jul 24, 2008 at 01:31 UTC | |
|
Re: Can I make Perl ignore a special char when matching?
by jethro (Monsignor) on Jul 23, 2008 at 22:55 UTC |