Skip to content

Instantly share code, notes, and snippets.

@aosteraas
Created April 14, 2012 08:23
Show Gist options
  • Save aosteraas/2382870 to your computer and use it in GitHub Desktop.
Save aosteraas/2382870 to your computer and use it in GitHub Desktop.
Part of the about_regular_expressions.rb in RubyKoans that I don't understand
# I don't understand this at all
def test_slash_w_is_a_shortcut_for_a_word_character_class
# NOTE: This is more like how a programmer might define a word.
assert_equal "variable_1", "variable_1 = 42"[/[a-zA-Z0-9_]+/]
assert_equal "variable_1", "variable_1 = 42"[/\w+/]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment