(http([s]?)://?)(([a-zA-Z0-9]+(.?))+)([a-zA-Z0-9]+((.[a-zA-Z]{2,5}){1,2})((/[a-zA-Z0-9?&=_-~:/?#[]@!$&'()*+,;]*)*)((.[a-zA-Z]{2,5}){0,2}))
This is my regex which is working well for matching the links in the string. But I don't want it to select every link. If a link has ">
before it, or </a>
after it, that link shouldn't be mathced. How can it be done?
These should be matched:
adasdas http://www.stackoverflow.com asdasas
adasdasahttp://www.stackoverflow.com/something asdas
These should NOT be matched:
adasdas<a href="somelink"> http://www.stackoverflow.com </a>asdasas
adasdasa<a href="somelink">http://www.stackoverflow.com/something</a> asdas
Why do I need this?: I want every link to be clickable even if it isn't between anchor tags.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…