Not operator

Learned a new trick today for getting a regex to return a desired result. The following regex will find html anchor tags. The [^>] is the key part to make this work. The ^ is the regex NOT operator, so basically this says accept all characters until the next >. Very handy.

(?i)]+)>(.+?)</a>

Note: this expression isn't displaying properly, look it up with the link below.

http://www.mkyong.com/regular-expressions/10-java-regular-expression-examples-you-should-know/

No comments:

Post a Comment