Is it possible to add a target="_blank"
to all <a>
tags, with just one regular expression? I've been experimenting with negative and positive look aheads/behinds, to no avail. This should:
- Match anchor tags whose
href
starts withhttp://
- If the anchor tag does not have a
target
tag, adds atarget="_blank"
tag - If it does have a
target
tag, it checks if thetarget
tag is not already set to"_blank"
, and if not it is replaced totarget="_blank"
Is this possible? If not, what would be the least computationally intensive way to do this?