Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/regex_lab.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
def starts_with_a_vowel?(word)

!!(word.match(/\A[aeiouAEIOU]/))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!!(word.match(/\A[aeiouAEIOU]/))
word.match?(/\A[aeiouAEIOU]/)

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[A-Z][a-z]*.*[.!?]\z/))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!!(text.match(/\A[A-Z][a-z]*.*[.!?]\z/))
text.match?(/\A[A-Z][a-z]*.*[.!?]\z/)

end

def valid_phone_number?(phone)

!!(phone.match(/\A(\d{10}|\(\d{3}\)\d{7}|\(\d{3}\)\s?\d{3}[-.\s]?\d{4}|\d{3}[-.\s]?\d{3}[-.\s]?\d{4})\z/))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!!(phone.match(/\A(\d{10}|\(\d{3}\)\d{7}|\(\d{3}\)\s?\d{3}[-.\s]?\d{4}|\d{3}[-.\s]?\d{3}[-.\s]?\d{4})\z/))
phone.match(/\A(\d{10}|\(\d{3}\)\d{7}|\(\d{3}\)\s?\d{3}[-.\s]?\d{4}|\d{3}[-.\s]?\d{3}[-.\s]?\d{4})\z/)

end