views:

35

answers:

2

Hi i have a following huge string format

example format :

p=" --0016367d537a47795e0489ecb3c7\nContent-Type: text/plain; charset=ISO-8859-1\n\nok this is tested here\n and again going to test it \n\n\nOn Sat, Jun 26, 2010 at 4:20 PM, kumar \n <[email protected]> wrote:\n\n>"

From the above huge string i need only the following content from it.

"ok this is tested here \n and again going to test it" 

I have implement the following Regular Expression but no use my regular exp is as follows

p.match(/(^\n\n*.*\n\n)/)

But is format doesn't returns the desired out put ..... can any one please help out

A: 

You are using \n which is not matching the backspace as this is a key regex character. In order to find the \ as part of your match you must use \\.

Here's an example that I've tested to match the group you require:

\\n\\n([\s\S]+)\\n\\n\\n
Brian Scott
+2  A: 
irb(main):008:0> p.split("\n\n")[1]
=> "ok this is tested here\n and again going to test it "
S.Mark
Yes !!!!!!!! this did a trick .Thanks lot S. Mark thank you so much
palani