J. Doe J. Doe - 5 months ago 35
Ruby Question

How to improve my RegEx to get the text before the pattern?

For example I have the next text:

Hello, my name is %{John}.

Now, I want to take all text before
. For this I'm using the next RegEx:


It works, but it includes
this part too. I do not need that. How can I take whole text, but exclude


Try this:


see http://www.rubular.com/r/YHcuSxMIA8