Re: [pcre-dev] Help with palindrome matching

Página superior
Eliminar este mensaje
Autor: Spoon Reloaded
Fecha:  
A: pcre-dev
Asunto: Re: [pcre-dev] Help with palindrome matching
On Tue, Sep 15, 2009 at 2:43 AM, Philip Hazel <ph10@???> wrote:
> Meanwhile, here is a palindrome-matching pattern
> that I was sent some years ago; it differs from your requirements
> because it ignores spaces and punctuation, and looks only at word
> characters. I don't know how it works, but it recognizes palindromes
> such as "A man, a plan, a canal, Panama!".
>
> /^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/i


It still doesn't work on "ababa"

>
> Hm, I see that *this* pattern also makes Perl 5.10 loop.
> Using that pattern, with all instances of \W* removed, seems to work in
> both Perl and PCRE:
>
> PCRE version 7.9 2009-04-11
>
> /^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/


This also does not work on "ababa". I have PCRE version 7.8 2008-09-05