Simon Strandgaard <neoneye / gmail.com> writes:

> palindrome = Regexp.new(<<'EOPALIN')
> (?x)(?i)\b
> 	(?:(\S)                (?:\s|\p)*
> 		(?:\S|(\S)         (?:\s|\p)*
> 			(?:\S|(\S)     (?:\s|\p)* 
> 				(?:\S|(\S) (?:\s|\p)* 
> 				\4)?       (?:\s|\p)* 
> 			\3)?           (?:\s|\p)*
> 		\2)?               (?:\s|\p)*
> 	\1)
> \b
> EOPALIN
>
> p "Win a Toyota blah".match(palindrome).to_s
> p "Why Abba rocks?".match(palindrome).to_s
> p "A Mismatch".match(palindrome).to_s

And what if I have a palindrome longer than eight chars?

-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org