0

So far this captures everything i need ending with 'em' i need regex to capture paragraphs ending in 'ppp' also.

My regex:

%<h2>Storyline</h2>(.*)em%s 
2
  • What? Could you give an example of what you want captured, and what you don't want captured? Commented Jan 9, 2011 at 11:40
  • Anything that starts with <h2>Storyline</h2> and ends with em OR ppp (stops capturing at the first occurrence of em OR ppp) Commented Jan 9, 2011 at 11:42

1 Answer 1

1

I would advise not to parse HTML with regex, but this seems easy enough seeing as you aren't actually parsing it as HTML...

%<h2>Storyline</h2>(.*?)(?:em|ppp)%s 
Sign up to request clarification or add additional context in comments.

3 Comments

Why shouldn't HTML be parsed with regex?
If your HTML consists of a very simple format or one-liner then there is nothing wrong with using regex. However if the structure is unpredictable or large, you're much better off using a parser, like DOMDocument, which will handle all the parsing of the markup for you so you can focus on getting the information from the markup.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.