js中类似explode的方法
来源:互联网 发布:吃鸡网络延迟检测 编辑:程序博客网 时间:2024/05/16 01:31
js的缺点之一就是函数库太少,自己搜了很多函数,其中这个explode很有用,在java也好,php也好,都有类似的分割字符串为数组的方法,不过要是想在js中用,那么只能自己手写了。
下面这个函数是较好用的一个:
function explode(inputstring, separators, includeEmpties) { inputstring = new String(inputstring); separators = new String(separators); if(separators == "undefined") { separators = " :;"; } fixedExplode = new Array(1); currentElement = ""; count = 0; for(x=0; x < inputstring.length; x++) { str = inputstring.charAt(x); if(separators.indexOf(str) != -1) { if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) { } else { fixedExplode[count] = currentElement; count++; currentElement = ""; } } else { currentElement += str; } } if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) { fixedExplode[count] = currentElement; } return fixedExplode;}
- js中类似explode的方法
- JS中字符串与数组的转换,类似PHP的explode
- JS中获取类似JSP 中的basePath的方法
- 关于JS中类似Java的类.方法名
- 原生JS中有着类似功能的方法性能对比
- c#中实现类似js的Eval方法(2011-03
- 重写PHP的explode方法
- 类似explode, 但不分割指定符号内的字符.
- Flex类似js里面getElementById的方法
- PHP中explode和implode的区别
- php中explode与split的区别
- php中explode与split的区别
- PHP中split()和explode()的区别
- php中explode与split的区别
- php中 implode() 和explode()的区别
- Cocoa 中类似MessageBox的方法
- 实战c++中的string系列--string的分割、替换(类似string.split或是explode())
- 类似php的js数组的in_array函数自定义方法
- Ubuntu软件源
- 【Cocos2d-x游戏引擎开发笔记(9)】实现DotA的技能冷却效果
- Java 中String转化为byte数组
- MFC读取操作文件
- 中国经济稳中求进又是一年
- js中类似explode的方法
- 有待试用,查看是谁锁住了我的数据库
- Spring源代码分析-Persist--JdbcTemplate
- iframe导航
- js"无缝"滚动原理(解决IE与"火狐"的差异)
- org.apache.jasperException:the absolute uri:http://kava.sun.com/jsp/jstl/c
- OReilly JavaScript The Good Parts 关于变量的使用
- JVM编译时和运行时,内存的分配
- servlet配置详解