This article describes the usage of split and replace in js. Share it for your reference. The specific analysis is as follows:
1. split:
Copy the code as follows: <html>
<head>
<title>
Registration list for continuing education for practitioners--print check-in form sdfsd</tr><tr></tr> sdfsd
</title>
</head>
<body>
<script type="text/javascript">
var str = "1231<tr id=/"123/">sdfsd</tr><tr></tr>";
alert(str);
var lst1 = str.split("<tr id=/"123/">");
alert(lst1[1]);
var lst2 = lst1[1].split("</tr>");
alert(lst2[0]);
var str2 = "";
for(var i = 1;i<lst2.length; i++)
{
if(i == 1)
str2 += lst2[i];
else
str2 += "</tr>" + lst2[i];
}
alert(str2);
var strReturn = lst1[0] + "<head><tr id=/"123/">" + lst2[0] + "</tr></head>" + str2;
alert(strReturn);
</script>
</body>
</html>
2. replace
The code copy is as follows: strHtml = strHtml.replace("<TR class=gridview_Header align=middle>", "<THEAD><TR class=gridview_Header align=middle>");
strHtml = strHtml.replace("</TR>", "</TR></THEAD>");
I hope this article will be helpful to everyone's JavaScript programming.