WEB开发网
开发学院网页设计JavaScript Dojo学习笔记(5. dojo.lang.array & dojo.lan... 阅读

Dojo学习笔记(5. dojo.lang.array & dojo.lang.func & dojo.string.extras)

 2010-09-14 13:31:40 来源:WEB开发网   
核心提示: dojo.string.isBlank判断输入字符串是否为空或全是空白字符,如果传入对象为非字符串则也会返回trueUsage Example:dojo.string.isBlank("1"); //will return falsedojo.string.escape

dojo.string.isBlank

判断输入字符串是否为空或全是空白字符,如果传入对象为非字符串则也会返回true

Usage Example:
 dojo.string.isBlank(" 1 "); //will return false
dojo.string.escape

参数1为type,可传值为: xml/html/xhtml, sql, regexp/regex, javascript/jscript/js, ascii

将按照所传type对字符串进行编码

Usage Example:
 dojo.string.escape("html", "<input type='text' value='' />"); //will return "<input
type='text' value='' />"
dojo.string.encodeAscii
dojo.string.escapeXml
dojo.string.escapeSql
dojo.string.escapeRegExp
dojo.string.escapeJavaScript
dojo.string.escapeString

这些函数也就是 dojo.string.escape 所调用的,这里无需多说

dojo.string.summary

取得输入字符串的缩略版本

Usage Example:
 dojo.string.summary("1234567890", 5); //will return "12345..."
dojo.string.endsWith

判断输入字符串是否以指定的字符串结尾

Usage Example:
 dojo.string.endsWith("abcde", "E"); //will return false
 dojo.string.endsWith("abcde", "E", true); //will return true
dojo.string.endsWithAny
判断输入字符串是否以指定的任意字符串结尾

Usage Example:

dojo.string.endsWithAny("abcde", "E", "e"); //will return true

dojo.string.startsWith

判断输入字符串是否以指定的字符串开头

Usage Example:
 dojo.string.startsWith("abcde", "A"); //will return false
 dojo.string.startsWith("abcde", "A", true); //will return true
dojo.string.startsWithAny
判断输入字符串是否以指定的任意字符串开头

Usage Example:
 dojo.string.startsWithAny("abcde", "A", "a"); //will return true
dojo.string.has

判断输入字符串是否含有任意指定的字符串

Usage Example:
 dojo.string.has("abcde", "1", "23", "abc"); //will return true
dojo.string.normalizeNewlines
按要求转换回车换行的格式

Usage Example:
 dojo.string.normalizeNewlines("arnbrn", "r"); //will return "arbr"
dojo.string.splitEscaped

将字符串按分隔符转换为数组

Usage Example:

dojo.string.splitEscaped("a\_b_c", '_'); //will return ["a\_b", "c"]

上一页  1 2 3 4 

Tags:Dojo 学习 笔记

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接