From: Xavier Noria Date: 2010-09-22T06:02:02+09:00 Subject: Re: comparing the first half of a string to the second half On Tue, Sep 21, 2010 at 10:55 PM, Adam Prescott wrote: > I think a regular expression is probably the most succinct, cleanest > approach for this: > > s = "Cyano The Cat" * 2 > if s =~ /^(.+)\1$/ >  puts $1 > end Clever, but almost: "aa\n" passes and it shouldn't. For an arbitrary string you want \A and \z (and /m).