in reply to Re: Try this in Regexp palindrome
in thread Try this in Regexp palindrome
You can also simplify your search by putting the pattern in a lookahead and doing a while-global match:
If you change the * to a + in the reverse version, you exclude single-character palindromes. The lookahead while-global trick helps here, too:$_ = 'abcdegedfc'; # Try it without the g, too. my $re; $re = qr/((.)(?:(??{$re})|.?)\2)/; print "$1\n" while (/(?=$re)/g);
$_ = 'abcdegedfc'; print "$1\n" while (/(?=((.+).?(??{quotemeta reverse $2})))/g);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Try this in Regexp palindrome
by bart (Canon) on Mar 21, 2005 at 17:21 UTC |