Reputation: 845
How do I match the end of a regular expression by a word? For example:
<h1><a href=...></a>CONTENT</h1>
Given that <h1>
is the start tag, how do I return <a href=...></a>CONTENT
?
The expression /< h1>(([<\/h1>\b])*/
does not seem to work
Upvotes: 2
Views: 1192
Reputation: 19466
What makes most regular expressions difficult, is the fact that they're greedy by default. By making them ungreedy using the U
modifier, writing something like this becomes very trivial. The following should work.
/<h1>(.*)<\/h1>/U
Upvotes: 0