这篇文章主要介绍了js字符串操作方法,实例分析了javascript中slice、substr及substring等方法的使用技巧,需要的朋友可以参考下
?
1 2 3 4 5 var str="This is my first Script code."; document.write("原字符串为:"+str+"<br>") document.write("第五个字符之后的部分:"+str.slice(5,-1)+"<br>"); document.write("第五个字符之后的15个字符:"+str.substr(5,15)+"<br>"); document.write("第五个字符后至第15个字符:"+str.substring(5,15)+"<br>");希望本文所述对大家的javascript程序设计有所帮助。
注< >:更多精彩教程请关注三联编程