oxo oxo - 1 month ago 5x
Ruby Question

How do I remove all characters in a string until a substring is matched, in Ruby?

Say I have a string:

Hey what's up @dude, @how's it going?

I'd like to remove all the characters before


or with the regex:

str = "Hey what's up @dude, @how's it going?"
str.gsub!(/.*?(?=@how)/im, "") #=> "@how's it going?"

you can read about lookaround at here