Introduction to Regular Expressions

Difficulty:
Easy

Tags:
strings, regular expressions

Instructions:
Write a regular expression that will match emails in a string.

Code:
assert_equal "john@mail.com to jane@mail.com".scan(/___/), ["john@mail.com", "jane@mail.com"]
assert_equal "why@ @chunkybacon.com why@chunkybacon.com".scan(/___/), ["why@chunkybacon.com"]
assert_equal "why @ @ why@chunkybacon".scan(/___/), []

Your Solution

Ruby 1.9.3

Back to Problems