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

Snippets has posted 5883 posts at DZone. View Full User Profile

Variable-length Negation

  • submit to reddit
        Everybody known the
construction to match a tag. But how to match inside a tag ? We want something like:
but it don't work since [^div] has not this meaning ;)

This regexp do that (but don't manage nested markups, however).

  (?!</div>) # If not followed by </div>
  . # Match any character
)* # Non-capturing grouping