From: Simon Strandgaard Date: 2005-09-02T07:24:05+09:00 Subject: Re: palindrome finder On 9/1/05, Josh Charles wrote: > I've been working on this piece of code and it's starting to drive me > crazy. I think it's a problem with reference vs value type, but I'm > not sure. I'm just writing a simple program to process a list of > words and print out all the palindromes (words that read the same > forward and backward) [snip] 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 -- Simon Strandgaard