For clarification, we need an exact question in the file about_regular_expressions.rb
, which I am having problems with:
def test_sub_is_like_find_and_replace assert_equal __, "one two-three".sub(/(t\w*)/) { $1[0, 1] } end
I know the answer to this question, but I do not understand what is going on to get the answer. I'm new to Ruby and regex, and in particular, I'm confused by the code between the curly braces and how this comes into play.
Dave wilson
source share