KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm not sure if my brain is worn out or if I'm just thinking about this too hard. The following code is from the about_regular_expressions in the Ruby Koans . def test_asterisk_means_zero_or_more assert_equal "abb", "abbcccddddeeeee"[/ab*/] assert_equal "a", "abbcccddddeeeee"[/az*/] assert_equal "", "abbcccddddeeeee"[/z*/] # THINK ABOUT IT: # # When would * fail to match? end How do you get * to fail a match? When I say fail, I'm assuming they mean they want assert_equal to return nil . I know one way would be to throw a \ in front of the * to make the regex explicitly look for the * character but I'm pretty sure this isn't what they were implying.
Tags (comma-separated)
Save Edits
Cancel