Commit 34fc856a authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2890 from jbreeden/sub_pattern_not_found

Don't crash if pattern not found for sub
parents 6c94b2d9 08c12ab7
......@@ -111,6 +111,7 @@ class String
def sub(*args, &block)
if args.size == 2
pre, post = split(args[0], 2)
return self unless post # The sub target wasn't found in the string
pre + args[1].__sub_replace(pre, args[0], post) + post
elsif args.size == 1 && block
split(args[0], 2).join(block.call(args[0]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment