in reply to Re^3: regex at word boundary
in thread regex at word boundary

Regarding the length $^N > 1 test, I added that because while refining this RE I discovered that it was capable of considering a single-character string to be palindromic (new word?), since "a" in reverse is still "a".

Update: Now that I think about it, the length $^N > 1 test is better written as ..+ earlier in the RE, like this:

qr/(..+) (??{ ( lc $^N eq reverse lc $^N ) ? '' : '(?!)' }) /ix

...thus forcing at least two characters to be tested in the first place, rather than hand-coding a test for two or more characters via 'length'. Duh!


Dave

Replies are listed 'Best First'.
Re^5: regex at word boundary
by QM (Parson) on Dec 08, 2005 at 05:25 UTC
    It must be the late hour, because I missed that (.+) would give trivial palindromes of length 1.

    I prefer (.{2,}) over (..+), as those dots tend to fade into the background.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of