Help with regex and <p> tag

Hi,

I need to create a regex to extract 4 paragraphs of a text:

Topic –

abc

abcd

abcde

abcdef

abcdefg

I need to extract 4 paragraphs (text inside

including some html code) of this text using a regex.

How can I solve this problem ? I’ve tried a lot but I cant do this.

Thanks in advance.

Hi,

I need to create a regex to extract 4 paragraphs of a text:

Topic –

abc

abcd

abcde

abcdef

abcdefg

I need to extract 4 paragraphs (text inside

including some html code) of this text using a regex.

How can I solve this problem ? I’ve tried a lot but I cant do this.

The standard advice would be to not use regular expressions - use an html parser like nokogiri.

Fred

Yes sir. Thanks for the tip.

This code makes the magic:

doc = Nokogiri::HTML(“

test

”)

doc.search(“p”)