From: dblack@... Date: 2006-04-05T09:35:47+09:00 Subject: Re: compare to strings Hi -- On Wed, 5 Apr 2006, Clint Pidlubny wrote: > Hello, > > What is the best approach to searching a string for another string? > > For instance, I have: > > url1 = 'http://www.url.com' > url2 = 'http://www.url.com/page' > > If part of url1 is in url2, like above, I'd like to declare it a > match. I'm sure this happens using a regular expression, but my > experience is limited with them. > > The other problem is that I'm not going to be looking for just one > url1, but I have an entire database table full of those to compare to > an entire database table of url2. > > Any thoughts on approaching this problem are appreciated. It's not a complete answer, but in case it helps: String has an include? method: url2.include?(url1) => true David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black