我爱Aspx >> Asp.Net >> 用 JavaScript 操作字符串? toUpperCase() – 将整个字符串转成大写字母。
注意: concat 、 match 、 replace 和 search 函数是在 JavaScript 1.2 中加入的。所有其它函数在 JavaScript 1.0 就已经提供了。
下面让我们看一下如何在 JavaScript 使用这些函数。下面的代码是用到了前面提到的所有函数:
function manipulateString(passedString1, passedString2) {
var concatString;
// The string passed to concat is added to the end of the first string
concatString = passedString1.concat(passedString2);
alert(concatString);
// The following if statement will be true since first word is Tony
if (concatString.charAt(3) == "y") {
alert("Character found!");
}
// The last position of the letter n is 10
alert("The last index of n is: " + concatString.lastIndexOf("n"));
// A regular expression is used to locate and replace the substring
var newString = concatString.replace(/Tony/gi,"General");
// The following yields Please salute General Patton
Ҷƪл˵?
JavaScript中this关键字使用方法..[05-20]
预装载以及JavaScript Image()对..[05-20]
用ASP动态生成JavaScript的表单验..[05-20]
JavaScript去除空格的三种方法 (..[05-20]
[翻译]JavaScript和Macromedia F..[05-20]
Javascript 弹出新窗口并向窗口中..[05-20]
JavaScript实用的一些技巧[05-20]
JavaScript对象与数组参考大全[05-20]
window.showModalDialog及window..[05-20]
Javascript 随机广告[05-20]
JavaScript中this关键字使用方法..[05-20]
[例程]使用VBScript 中的类组织开..[05-20]
预装载以及JavaScript Image()对..[05-20]
RAID1--5技术详解[05-20]
Linux系统的字型设定方法[05-20]
关于PS命令的使用详解[05-20]
ls命令选项详解[05-20]
对于passwd 命令的使用详解[05-20]
关于su命令使用详解[05-20]
关于chattr 命令使用详解[05-20]