Skip to content

Instantly share code, notes, and snippets.

@craigsdennis
Last active August 29, 2015 14:21
Show Gist options
  • Save craigsdennis/d9f6943c7cf5ab9fa8b6 to your computer and use it in GitHub Desktop.
Save craigsdennis/d9f6943c7cf5ab9fa8b6 to your computer and use it in GitHub Desktop.
Regular Expression example in Ruby
title = "Regular Expressions in 10 different languages"
# Nil if match not found
result = /.*\d+.*/.match(title)
# And extraction too
result = /(\d+)/.match(title)
if result
puts "There are %s languages represented" % result[1]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment