diff --git a/lib/regex_lab.rb b/lib/regex_lab.rb index 60552ab..27510a7 100644 --- a/lib/regex_lab.rb +++ b/lib/regex_lab.rb @@ -1,19 +1,19 @@ def starts_with_a_vowel?(word) - +word.match(/^[aiuoeAIUOE]/)? true :false end def words_starting_with_un_and_ending_with_ing(text) - +text.scan(/\bun\w+ing\b/) end def words_five_letters_long(text) - +text.scan(/\b\w{5}\b/) end def first_word_capitalized_and_ends_with_punctuation?(text) - +text.match(/^[A-Z].+[.!?]$/) ? true : false end def valid_phone_number?(phone) - +phone.match(/([0-9] *?){10}|(\([0-9]{3}\)(([0-9]{3}-[0-9]{4})|[0-9]{7})\b)$/) ? true : false end diff --git a/spec/regex_lab_spec.rb b/spec/regex_lab_spec.rb index 4d54f4e..11b430b 100644 --- a/spec/regex_lab_spec.rb +++ b/spec/regex_lab_spec.rb @@ -23,7 +23,7 @@ describe "#words_starting_with_un_and_ending_with_ing" do it "returns an array with the words starting with 'un' and ending with 'ing'" do words_string = "unassuming ambiguous understanding pomp circumstance uninteresting uncompromising grouchy corollary" - + expect(words_starting_with_un_and_ending_with_ing(words_string).count).to eq(4) expect(words_starting_with_un_and_ending_with_ing(words_string)).to include("understanding") expect(words_starting_with_un_and_ending_with_ing(words_string)).not_to include("pomp") @@ -68,7 +68,7 @@ it "returns false for invalid phone numbers, regardless of formatting" do valid_numbers = ["28894546", "(718)891-13135", "234 43 9978", "(800)IloveNY"] - expect(valid_numbers.all? { |number| valid_phone_number?(number) }).to be(false) + expect(valid_numbers.all? { |number| !valid_phone_number?(number) }).to be(true) end end