in reply to Re^2: regex at word boundary
in thread regex at word boundary
I would point out the existence of (?!), which I'm told always fails, though I'm not sure I understand it.'1\b2'
Update 1:
By the way, in my solution I chose to accept palindromes regardless of whether they contain only alpha characters or not.Yes. The OP was looking for multi-word palindromes, perhaps more along the lines of the "interesting to humans" variety, which seems to be what started the thread in the first place.
Update 2: After further examination, your idea could be adapted for intervening whitespace (or indeed any noise characters) if the regex engine was re-entrant (is that with or without the hyphen?). Something like:
which might be further streamlined to(??{ local $N; ($N = $^N) =~ s/\w+//g; (lc $N eq reverse lc $N) ? '' : (?!) })
I think length $^N > 1 is superfluous, as length $^N is sufficient as a test, and (.+) would always be positive anyway (or is there a zero length character that would match?)(??{ local $N; ($N = $^N) =~ s/\w+//g; (?!) if (lc $N ne reverse lc $N) })
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: regex at word boundary
by davido (Cardinal) on Dec 08, 2005 at 05:03 UTC | |
by QM (Parson) on Dec 08, 2005 at 05:12 UTC | |
|
Re^4: regex at word boundary
by davido (Cardinal) on Dec 08, 2005 at 05:10 UTC | |
by QM (Parson) on Dec 08, 2005 at 05:25 UTC | |
|
Re^4: regex at word boundary
by davido (Cardinal) on Dec 08, 2005 at 05:57 UTC | |
by QM (Parson) on Dec 10, 2005 at 05:46 UTC | |
by davido (Cardinal) on Dec 10, 2005 at 05:56 UTC | |
by mikeraz (Friar) on Dec 12, 2005 at 16:08 UTC | |
by QM (Parson) on Dec 12, 2005 at 17:48 UTC | |
by mikeraz (Friar) on Dec 12, 2005 at 18:04 UTC |