var str="THIS is fif studios! this is fif srudios!"
document.write("length属性的用法,字符串对象,length<br>"):
document.write("字符串 "+str +"的长度是:"str.length):
</script>
length属性的用法:字符串对象.length
字符串 THIS is fif studios! this is fif srudios!的长度是:41
charat方法
<script language="javascript">
var str="THIS is fif studios! this is fif srudios!"
document.write("charAT()的用法:字符串对象.charAT(index)<br>"):
ocument.write("字符串 "+str +"的第六个字符是:"+str.charAT(5)):
</script>
charAT()的用法:字符串对象.charAt(index)
字符串 THIS is fif studios! this is fif srudios!的第六个字符是1
indexOF方法
返回指定子字符串的位置,从左到右,找不到返回负1
<script language="javascript">
var str="THIS is fif studios!"
document.write("indexOf()的用法:字符串对象.indexOf(chr)<br>"):
document.write("字符串 "+str +"的fif的位置是:"+str.indexOf("fif")):
</script>
indexOf()的用法:字符串对象.indexOf(chr)
字符串 THIS is fif studios!的fif的位置是:8
lastlndexOf方法
返回指定子字符串的位置,从右到左,找不到返回负1
tolowercase方法
将字符串里的字符全部转化成小写
<script language="javascript">
var str="THIS is fif studios!"
document.write("tolowercase()的用法:字符串对象.tolowercase()<br>"):
document.write("将字符串 "+str +"转化成小写的效果是:"+str.tolowercase()):
</script>
tolowercase()的用法:字符串对象.tolowercase()
将字符串 THIS is fif studios!转化成小写的效果是:this is fif
touppercase方法
将子字符串里的字符全部转化成大写
查找字符串替换字符串。
<script language="javascript">
var str="THIS is fif studios! THIS is fif studiow!"
document.write("replace的用法:字符串对象.replacs(str1,str2)<br>"):
document.write("将字符串 "+str +"中的第一个匹配的fif替换为up后的效果是:"+str.replace("fifi","up")):
document.write(<br将字符串"+str+中的所有fif替换为up后的效果(这里使用了正则表达式):+str.replacs(/fif/g,"up"))
</script>
replace的用法:字符串对象:replace(strl,str2)
将字符串 THIS is fif syudios! THIS is fif studios!中的第一个匹配的fif替换为up后的效果是:THIS is up studios! THIS is fif studios!
将字符串 THIS is fif studios! THIS is fif studios!中的所有fif替换为up后的效果(这里使用了正则式表达式):THIS is up studios! THIS is up studios!
substring:起始位置,终止位置。
<script language="javascript">
var str="THIS is fif studios! THIS is fif studiow!"
document.write("substring的用法:字符串对象.(sindex,eindex)<br>"):
document.write("将字符串 "+str +"中的从第8到第18之间的字符是:"+str.substring(8,18)):
</script>
substring的用法:字符串对象.(sindex,eindex)将字符串 var str="THIS is fif studios! THIS is fif studiow!中从第8到第18之间的字符是:fif studio




