"abcdefg".substring(4,2)
返回的值为:ef
从字符串"abcdefg"中第4位开始取,取到第2位。
"abcdefg".substring(4)
返回:efg
从字符串"abcdefg"中第4位开始取,取到字符串的尾部
{
html2 = html.toLowerCase();
var result = "";
var temp7 = "";
if(html.indexOf("<a") == -1)
{
return html2;
}
while(html2.indexOf("<a")!=-1)
{
var temp = html2.substring(0,html2.indexOf("<a")+2);
var temp2 = html2.substring(html2.indexOf("<a")+2);
var temp3 = temp + temp2.substring(0,temp2.indexOf(">")+1);//...<a >结束
var temp4 = html2.substring(html2.indexOf(temp3)+temp3.length);//<a>之后
var temp5 = temp4.substring(0,temp4.indexOf("</a>"));//<a>之间</a>
temp7 = temp4.substring(temp4.indexOf("</a>")+4);//</a>之后
var temp6 = "";
var brk = false;
for(var i = 0 ; i < temp5.length;i++)
{
if(temp5.charAt(i)=='<')
{
brk = true;
}
if(temp5.charAt(i)=='>')
{
brk = false;
}
if(brk)
{
temp6 += temp5.charAt(i);
continue;
}
temp6 += temp5.charAt(i)+"<!---->";
}
result += temp3 + temp6+"</a>";
html2 = temp7;//控制继续判断循环
}
return result+temp7;
}
5月以来,多家<A href="http://www.baidu.com"><FONT color=#ee3d11>基金</FONT></A>公司...
temp=5月以来,多家<A
temp2= href="http://www.baidu.com"><FONT color=#ee3d11>基金</FONT></A>公司...
temp3=5月以来,多家<A href="http://www.baidu.com">
temp4=<FONT color=#ee3d11>基金</FONT></A>公司...
temp5=<FONT color=#ee3d11>基金</FONT>
temp7=公司...
temp6=<FONT color=#ee3d11>基<!---->金</FONT>
result=5月以来,多家<A href="http://www.baidu.com"><FONT color=#ee3d11>基<!---->金</FONT></a>
result+temp7=5月以来,多家<A href="http://www.baidu.com"><FONT color=#ee3d11>基<!---->金</FONT></a>公司...
|
indexof() :在字符串中从前向后定位字符和字符串;所有的返回值都是指在字符串的绝对位置,如为空则为- 1 string test="asdfjsdfjgkfasdsfsgfhgjgfjgdddd"; test.indexof('d') =2 //从前向后 定位 d 第一次出现的位置 lastindexof() :在字符串中从后向前定位字符和字符串;、
他们接受字符数组做为变元,其他方法同上,返回数组中任何一个字符最早出现的下标位置 如下 char[] bbv={'s','c','b'}; lastindexofany 同上。 |