in reply to Try this in Regexp palindrome

use Regexp::Common; s/.*?($RE{lingua}{palindrome}).*/$1/s;
Note that it will leave just the 'a' from your example string, as it will find the longest, left-most palindrome in the string. Which in this case is the string 'a'.

Replies are listed 'Best First'.
Re^2: Try this in Regexp palindrome
by Roy Johnson (Monsignor) on Mar 21, 2005 at 13:58 UTC
    For me, it always matches one character; it never matches a nontrivial palindrome.
    use Regexp::Common; $_ = 'abcdegedfc'; while (/($RE{lingua}{palindrome})/g) { print "Got $1\n"; } __END__ Got a Got b Got c Got d Got e Got g Got e Got d Got f Got c

    Caution: Contents may have been coded under pressure.