var str = "<div><span><a href='foo'>foo<a></span></div>"; var reg = /href=[\x27\x22]*([^\x27\x22\x3E\s]*)[\x27\x22]*/i; alert(reg.exec(str)[1]);