var a = "abcDEfGgdefg32asdf38";document.write("原始:"+a+"<br />")document.write("粗體:"+a.bold()+"<br />");document.write("大號:"+a.big()+"<br />");document.write("斜體:"+a.italics()+"<br />");document.write("刪除線:"+a.strike()+"<br />");document.write("字體大小:"+a.fontsize(10)+"<br />");document.write("字體顏色:"+a.fontcolor("#ff0000")+"<br />");document.write("上標:"+a.sup()+"<br />");document.write("下標:"+a.sub()+"<br />");document.write("大寫:"+a.toUpperCase()+"<br />");document.write("大寫:"+a.toLowerCase()+"<br />");document.write("返回索引字符:"+a.charAt(3)+"<br />");//這里應該是"D"document.write("返回索引:"+a.indexOf("f")+"<br />");//這里應該是5document.write("返回索引(逆向查找):"+a.lastIndexOf("f")+"<br />");//這里應該是9document.write("查找字符串:"+a.search("f")+"<br />");//這里應該是5,與indexOf相同document.write("替換字符串:"+a.replace("a","A")+"<br />");//把字符串中的a替換成Adocument.write("返回子串:"+a.slice(1,3)+"<br />");//應該是bc,返回從索引1到3-1的子串document.write("分割字符串:"+a.split("D").toString()+"<br />");//把D作為分割符,分割字符串,返回數組document.write("返回子串:"+a.substr(1,2)+"<br />");//返回子串,從索引1開始,長度為2,這里就是bcdocument.write("返回子串:"+a.substring(1,3)+"<br />");//與sclice()相同,返回索引1到3-1的子串document.write("匹配:"+a.match(//d+/)+"<br />");//正則匹配,返回匹配的結果,這里是32
新聞熱點
疑難解答