This is a cool ruby feature to find substring. # [] - works like `match` method, but return substring, not #<MatchData "..."> 'string'[/str/] #=> "str" # The real benefit you get when you find part of substring 'string'[/s(t)r/, 1] #=> "t" 'string'.match(/s(r)r/)[1] #=> # NoMethodError: undefined method `[]' for nil:NilClass # from (irb):3 # And the coolest thing that it can be used without tmp variables 'string'[/s(r)r/, 1] #=> nil And real live code example #get country code from the phone '+12345678901'[/+(.*)\d{10}/, 1] Of course there are not all abilities of String#[] method. And you should be confident with using nil as returned value. So check out the Ruby docs for more info. Or RubyTaps #99.