Hi -- On Tue, 18 Apr 2006, Wes Gamble wrote: > unknown wrote: >> Hi -- >> >> On Tue, 18 Apr 2006, Wes Gamble wrote: >> >>> >>> If presented with >>> How can I just get the part of the string before the slash? >> How about: >> >> /[^\/]+/ # match one or more non-slash characters >> > That works well. > > Can you explain to me why > > /(.*)?\// > > matched the text in front of the "/" AND the "/" > > though > > ? Because you told it to :-) You've got a / in the pattern. (Keep in mind that the *whole* pattern matches, not just the part in parentheses. The parentheses are just for capturing submatches.) David -- David A. Black (dblack / wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" PDF now on sale! http://www.manning.com/black Paper version coming in early May!