From: Harry Ohlsen Date: 2003-11-19T09:03:54+09:00 Subject: Re: String startswith/endswith in Ruby? Hi David, > s = 'Hello, world!' > s.startswith('Hello') >> true > s.endswith('!') >> true > s.endswith('asdf') >> false How about this ... s =~ /^Hello/ # => true s =~ /!$/ # => true s =~ /asdf$/ # => false While using a regex to do something so simple seems a bit excessive, looking for a value at the start or end of a string is really just a special case of a more general problem, which regex matching solves very neatly. Hence, one can attack this kind of thing in a uniform manner. Cheers, Harry O.