Where did I go wrong in my regex lookaround?

Amazed

New Member
I'm trying to pull the first paragraph out of Markdown formatted documents: \[quote\] This is the first paragraph. This is the second paragraph. \[/quote\]The answer here gives me a solution that matches the first string ending in a double line break. Perfect, except some of the texts begin with Markdown-style headers: \[quote\] \[code\]###\[/code\] This is an h3 header. This is the first paragraph. \[/quote\]So I need to:
  • Skip any line that begins with one or more \[code\]#\[/code\] symbols.
  • Match the first string ending in a double line break.
In other words, return 'This is the first paragraph' in both of the examples above. So far, I've tried many variations on: \[code\]"/(?s)(?:(?!\#))((?!(\r?\n){2}).)*+/\[/code\]But I can't get it to return the proper match. Where did I go wrong in my lookaround?I'm doing this in PHP (preg_match()), if that makes a difference. Thanks!
 
Back
Top