当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JavaScript中split字符串函数

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 JavaScript中split字符串函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 285 ::
收藏到网摘: n/a

  JavaScript中split函数方法是将一个字符串分割为子字符串,然后将结果作为字符串数组返回。使用方法:

  stringObj.split( [separator[, limit]])

  其中stringObj是必选项。要被分解的 String 对象或文字。该对象不会被 split 方法修改。

  separator是可选项。字符串或 正则表达式 对象,它标识了分隔字符串时使用的是一个还是多个字符。如果忽略该选项,返回包含整个字符串的单一元素数组。

  limit是可选项。该值用来限制返回数组中的元素个数。

  split函数的结果是一个字符串数组,在 stingObj 中每个出现 separator 的位置都要进行分解。separator 不作为任何数组元素的部分返回。

  下面的示例演示了 JavaScript中split函数方法的用法。

function SplitDemo(){
 var s, ss;
 var s = "The rain in Spain falls mainly in the plain.";
 // 在每个空格字符处进行分解。
 ss = s.split(" ");
 return(ss);
}