栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

Javascript字符串对象的常用方法简明版

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Javascript字符串对象的常用方法简明版

var a = "abcDEfGgdefg32asdf38";
document.write("原始:"+a+"
") document.write("粗体:"+a.bold()+"
"); document.write("大号:"+a.big()+"
"); document.write("斜体:"+a.italics()+"
"); document.write("删除线:"+a.strike()+"
"); document.write("字体大小:"+a.fontsize(10)+"
"); document.write("字体颜色:"+a.fontcolor("#ff0000")+"
"); document.write("上标:"+a.sup()+"
"); document.write("下标:"+a.sub()+"
"); document.write("大写:"+a.toUpperCase()+"
"); document.write("大写:"+a.toLowerCase()+"
"); document.write("返回索引字符:"+a.charAt(3)+"
");//这里应该是"D" document.write("返回索引:"+a.indexOf("f")+"
");//这里应该是5 document.write("返回索引(逆向查找):"+a.lastIndexOf("f")+"
");//这里应该是9 document.write("查找字符串:"+a.search("f")+"
");//这里应该是5,与indexOf相同 document.write("替换字符串:"+a.replace("a","A")+"
");//把字符串中的a替换成A document.write("返回子串:"+a.slice(1,3)+"
");//应该是bc,返回从索引1到3-1的子串 document.write("分割字符串:"+a.split("D").toString()+"
");//把D作为分割符,分割字符串,返回数组 document.write("返回子串:"+a.substr(1,2)+"
");//返回子串,从索引1开始,长度为2,这里就是bc document.write("返回子串:"+a.substring(1,3)+"
");//与sclice()相同,返回索引1到3-1的子串 document.write("匹配:"+a.match(/d+/)+"
");//正则匹配,返回匹配的结果,这里是32

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/106575.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号