O'Reilly logo

Learning Rails: Live Edition by Edd Dumbill, Simon St. Laurent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Simplest Expressions: Literal Strings

The simplest regular expressions are simply literal strings. There are plenty of times when it’s enough to search against a fixed search pattern. For example, you might test for the presence of the string “Ruby”:

sentence = "Ruby is the best Ruby-like programming language."
sentence =~ /Ruby/
# => 0 - The first instance of 'Ruby' appears at position 0.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required