All pastes #506075 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-23 20:45 UTC
rendered paste body
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. <a href="http://www.booboo.com"><font></font></a>foo
2. <a href="http://www.foobar.com"></a>
3. <a HREF="http://www.mcgee.com">foo</a>

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 <a></a>, but not text (basically anything not enclosed by <>).