Skip to content

Instantly share code, notes, and snippets.

@conhanley
conhanley / phone_regex.rb
Last active Jan 23, 2018
Phone number regex example in IRB, for 67-272 lab teaching session
View phone_regex.rb
# INSTRUCTIONS:
# 1. Review the tests on lines 21 and 24.
# 2. Replace the placeholder RegEx on line 18 with one that would pass these tests.
# 3. Use the shell command 'irb phone_regex.rb' (no quotation marks) to evaluate this entire file.
# 4. If successful, repeat these steps to pass the tests on line 41, modifying your original RegEx as necessary.
# Part 1: Creating a regular expression for phone numbers
# ---------------------------
# Valid phone numbers
phone_pass = ['4123456789', '412-456-7890', '412.456.7890', '(412) 345-6789', '412 345-6789']