JS:1.8字符串(string)对象(length,indexOf(),lastIndexOf(),replace(),match(),toUpperCase(),toLowerCase())
2015-05-22 15:54
746 查看
string:字符串(string)对象 |
length属性
indexOf(),lastIndexOf()
replace()
match()
toUpperCase(),toLowCase()
JS:1.8.0,JavaScript String(字符串)对象 实例返回顶部 |
JS:1.8.1,length属性返回顶部 |
<html> <body> <script type="text/javascript"> var txt="Hello World!" //输出字符串的长度 document.write(txt.length) </script> </body> </html>
JS:1.8.2,indexOf(),lastIndexOf()返回顶部 |
<html> <body> <script language="javascript"> var txt="Hello world!"; // indexOf(),lastIndexOf() 来定位字符串中某一个指定的字符首次出现的位置 //若不存在则返回“-1” document.write(txt+"<br>"); document.write("该字符串的长度为:"+txt.length+" <br>"); document.write("从前往后找,第一位字符'l'它的索引位置为:"+txt.indexOf('l'+"<br>")); document.write("从后往前查,第一个字符'l'它的索引位置为:"+txt.lastIndexOf('l')+"<br>"); </script> </body> </html>
JS:1.8.3,replace()返回顶部 |
<html> <body> <h3>replace(要替换内容,替换成的内容)</h3> <script language="javascript"> var txt="某某喜欢王帅!"; document.write("替换前的内容:"+txt+"<br>"); document.write("替换后的内容:"+txt.replace("某某","凤姐")); </script> </body> </html>
JS:1.8.4,match()返回顶部 |
<html> <body> <script type="text/javascript"> var str="Hello world!" document.write(str.match("world") + "<br />") document.write(str.match("World") + "<br />") document.write(str.match("worlld") + "<br />") document.write(str.match("world!")) </script> </body> </html>
JS:1.8.5,toUpperCase(),toLowCase()返回顶部 |
<html> <body> <script language="javascript"> var txt="Hello world!"; document.write(txt+"<br>"); document.write("把所有字符转为大写:"+txt.toUpperCase()+"<br>"); document.write("把所有字符转为小写:"+txt.toLowerCase()); </script> </body> </html>
相关文章推荐
- 字符串字符JS:1.8,字符串(string)对象(length,indexOf(),lastIndexOf(),replace(),match(),toUpperCase(),toLowerCas
- JS:1.8,字符串(string)对象(length,indexOf(),lastIndexOf(),replace(),match(),toUpperCase(),toLowerCase())
- Javascript 中的 字符串对象 toUpperCase() toString() charAt() indexOf() lastIndexOf() replace() search() substring()
- 动手动脑之Stringequals()方法,整理String类的Length(),charAt(),getChars(),replace(),toUpperCase(),toLowerCase(),trim(),toCharArray()使用说明
- JS中的字符串是对象,包含许多与字符串数据交互的方法(lengh,charAt(),toUpperCase(),toLowerCase())
- 用lastIndexOf方法返回String对象内最后一次出现子字符串的字符位置的示例
- Java中常用的几种对字符串的处理(substring,split,indexOf,lastIndexOf,replace)
- js中substr,substring,indexOf,lastIndexOf,split,replace的用法详解
- Java中String类的length()、charAt()、getChars()、replace()、toUpperCase()、toLowerCase()、trim()、toCharArray()使用说明
- You're given a string of lower-case Latin letters. Your task is to find the length of its longest su
- JS indexOf() lastIndexOf()与substring()截取字符串的区别
- js字符串基础:IndexOf(),LastIndexOf(),substring()
- js中substr,substring,indexOf,lastIndexOf,split,replace的用法详解
- js中substr,substring,indexOf,lastIndexOf的用法小结
- 字符串中判断存在的几种模式和效率(string.contains、string.IndexOf、Regex.Match)
- string里的IndexOf、LastIndexOf、Substring的详解(意义和用法)
- js中substr,substring,indexOf,lastIndexOf的用法
- js中的字符串(string)的一些方法:toUpperCase(),indexOf(""),length
- JS数组filter()、map()、some()、every()、forEach()、lastIndexOf()、indexOf()实例
- js 判断字符串是否包含某字符串,String对象中查找子字符,indexOf