Reputation: 799
Here is code:
<div class="rightColoumn" id="divreports">
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon">
<link href="../ClientScript/General.css" rel="stylesheet" type="text/css">
</div>
I wish I could remove lines completely.
javascript String object strObject contains this html.
Upvotes: 0
Views: 773
Reputation: 1156
Here try this way to remove html tag
//link
var reg= /<link\b[^>]*?>/gi
return this
.replace(reg, '$1<link href="http://$2">$2>')
};
Upvotes: 0
Reputation: 2573
here's another way to remove < link tag lines:
strObject.replace(/^.*<link.*$/mg, "");
It will work if your string has line break '\n' at the end of each line.
Upvotes: 0
Reputation: 318182
How about just parsing it as what it is, HTML
var strObject = '<div class="rightColoumn" id="divreports"><link href="/favicon.ico" rel="shortcut icon" type="image/x-icon"><link href="../ClientScript/General.css" rel="stylesheet" type="text/css"></div>';
var parser = new DOMParser();
var doc = parser.parseFromString(strObject, "text/html");
var parent = doc.getElementById('divreports');
var links = parent.getElementsByTagName('link');
for (var i=links.length; i--;) parent.removeChild(links[i]);
Upvotes: 2