in reply to Re^3: regex at word boundary
in thread regex at word boundary
As you point out, the regexp engine is not re-entrant. But tr/// isn't a regular expression, and that can be used to strip away whitespace.
use strict; use warnings; use vars qw/ $N /; my $string = "God dog"; my $re = qr/^ (..+) (??{ local $N = lc $^N; $N =~ tr!\t \f!!d; ( $N eq reverse $N ) ? '' : '(?!)' }) $/ix; print "$string is", ( $string =~ $re ) ? "" : "n't" , " a palindrome\n";
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: regex at word boundary
by QM (Parson) on Dec 10, 2005 at 05:46 UTC | |
by davido (Cardinal) on Dec 10, 2005 at 05:56 UTC | |
by mikeraz (Friar) on Dec 12, 2005 at 16:08 UTC | |
by QM (Parson) on Dec 12, 2005 at 17:48 UTC | |
by mikeraz (Friar) on Dec 12, 2005 at 18:04 UTC |