On Wed, Nov 19, 2003 at 08:52:18AM +0900, Dave Benjamin wrote:
> Hi all,
> 
> I'm a Python user trying to learn a bit of Ruby. I was wondering if there's
> a common way of writing "startswith" and "endswith" expressions for strings
> in Ruby.
> 
> For instance:
> 
> s = 'Hello, world!'
> s.startswith('Hello')    >> true
> s.endswith('!')          >> true
> s.endswith('asdf')       >> false

Regular expressions are your friend:

  s =~ /^Hello/
  s =~ /!$/
  s =~ /asdf$/ 

Regards,

  Michael