DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Variable-length Negation
Everybody known the
<div[^>]*>
construction to match a tag. But how to match inside a tag ? We want something like:
<div>[^div]*</div>
but it don't work since [^div] has not this meaning ;) This regexp do that (but don't manage nested markups, however).
<div> (?: (?!</div>) # If not followed by </div> . # Match any character )* # Non-capturing grouping </div>





