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 />");//这里应该是5
document.write("返回索引(逆向查找):"+a.lastIndexOf("f")+"<br />");//这里应该是9
document.write("查找字符串:"+a.search("f")+"<br />");//这里应该是5,与indexOf相同
document.write("替换字符串:"+a.replace("a","A")+"<br />");//把字符串中的a替换成A
document.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,这里就是bc
document.write("返回子串:"+a.substring(1,3)+"<br />");//与sclice()相同,返回索引1到3-1的子串
document.write("匹配:"+a.match(/\d+/)+"<br />");//正则匹配,返回匹配的结果,这里是32

标签:
Javascript,字符串对象的常用方法

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“Javascript字符串对象的常用方法简明版”

暂无“Javascript字符串对象的常用方法简明版”评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。