[code lang="ruby"]
irb(main):001:0> "capture to here!  leave this off".gsub(/(.*\!).*(\s+.*)$/, "\\1 and \\2")
=> "capture to here! and  off"
[/code]

I looked in my Pickaxe, I looked in various tutorials, but this simple little thing hung me up more than many other Ruby questions I’ve had over the years.

Comments

  1. Txema said: »

    I can’t guess exactly what is the question.

    Are you trying:

    /(.!)s(.*)$/

    Hope2Help

Leave a Reply