You're right, the (corrected) code won't find palindromes. It wasn't intended to. It was the first step in finding a palindrome candidate.OK, fair enough. So what did you want it to do? Did you just want to check for repeated characters at the proper end of word boundaries?
[Insert "Lightbulb Over Head" graphic here ]
You just want a filter to grab candidates, then strip whitespace, then test for palindrome-ness.
I think you'd do us a favor by coming up with an appropriate regex with ??{code}, something near:
Though I don't think that works, and it's untested. (Hey, I have to leave something up to you.) Besides, there's a lot left out of the perlre with ?{code} and ??{code}, so please come back and tell us what it should say :)/(\b (([a-z]) # at least one char ?{local @suffix; push @suffix, $^N}) # build up suffix (([a-z) ?{local @suffix; push @suffix, $^N} | \S+)+ [a-z]? # possible odd char (([a-z]) (?{if ($^N eq $suffix[-1]) {pop @suffix}}) | \S+)+) (([a-z]) (?{if ($^N eq $suffix[-1]) {pop @suffix}}) \b) /x
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re^3: regex at word boundary
by QM
in thread regex at word boundary
by mikeraz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |