Ruby Backreference Pattern Matching for the Brain-Dead
- One minute read - 16 wordsirb(main):001:0> "capture to here! leave this off".gsub(/(.*\!).*(\s+.*)$/, "\\1 and \\2")
=> "capture to here! and off"
irb(main):001:0> "capture to here! leave this off".gsub(/(.*\!).*(\s+.*)$/, "\\1 and \\2")
=> "capture to here! and off"