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
/<h1>([\s\S]*)<\/h1>/
I think this should help you out.
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
forloop, and then requirements change, and new requirements are added, and before you know it you have a 2000-line function. Because everyone knows that you can never, ever change your design later. Refactoring is simply out of the question! Right?