in reply to Match a chunk
One thing strikes me about the 'reverse' regex approach you are using. If $s1 and $s2 are both 'pure' strings with no regex metacharacters (or with any metacharacters escaped), then the expression $s1 =~ /$s2/ is true if $s2 is a substring of $s1. If this is true and the match is reversed, $s2 =~ /$s1/ is true if $s2 equals $s1 by string comparison (i.e., $s2 eq $s1 is true).
So why not just use index (to find a substring) and eq (see the string Equality Operators) instead of trying to deal with the arcana of the operation of /g across multiple regexes?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Match a chunk
by dhasaan (Initiate) on Jun 13, 2008 at 13:36 UTC |