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