My regular expression right now: <[\s]*(a|A)[\s]*(href|HREF|Href)[\s]*=[\s]*"[^"]*"[\s]*>WHATGOESHERE<[\s]*/[\s]*(a|A)[\s]*> My test string: 1. foo 2. 3. foo The regular expression should match 1 & 2, but not 3. Basically, I am trying to catch empty links, so I want a regex that allows tags within tags, but not actual text. I don't know what to put in the "WHATGOESHERE" part that would allow tags within the , but not text (basically anything not enclosed by <>).