I have the following text in ruby, i want to extract only the part between —- and —- (the content) but I’m not able to do that, I tried with regex using:
mystring.match(/^-*(.*?)^-*/m)[1]
this is the text:
Congrats! You just got a new contact lead
Here's the information your contact submitted:
------------------------------------------------------------------------------------
Name: testing
Email: test123@gmail.com
Mensaje: hello
this is a nice test
------------------------------------------------------------------------------------
For your convenience, we have automatically added this contact and message to your account.
Best of luck!
- LeadABC
Try…
RubyFiddle.
However, this will break if there is a
-in your contents. It would probably be more robust if you accepted a bare minimum, such as 10-characters. You can use the{10,}quantifier to do this.RubyFiddle.
This version also ensures the number of
-matched are balanced (if it matched 16-characters at the start, it must match 16-characters at the end too).