dojo.string.substituteParams |
類似C#中的String.Format函數(shù)
%{name}要保證與傳入的對(duì)象的名稱大小寫一致,否則會(huì)出異常
Usage Example:
dojo.string.substituteParams("%{0} - %{1} - %{2}", "a", "b", "c"); //will return "a - b - c"
dojo.string.substituteParams("%{name}: %{value}", {name:"名稱",value:"值"}); //will return "名稱: 值" |
dojo.string.capitalize |
把每一個(gè)單詞的首字母大寫
Usage Example:
dojo.string.capitalize("show me love"); //will return "Show Me Love" |
dojo.string.isBlank |
判斷輸入字符串是否為空或全是空白字符,如果傳入對(duì)象為非字符串則也會(huì)返回true
Usage Example:
dojo.string.isBlank(" 1 "); //will return false |
dojo.string.escape |
參數(shù)1為type,可傳值為: xml/html/xhtml, sql, regexp/regex, javas cript/js cript/js, ascii
將按照所傳type對(duì)字符串進(jìn)行編碼
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.escapeJavas cript
dojo.string.escapeString
這些函數(shù)也就是 dojo.string.escape 所調(diào)用的,這里無(wú)需多說(shuō) |
dojo.string.summary |
取得輸入字符串的縮略版本
Usage Example:
dojo.string.summary("1234567890", 5); //will return "12345..." |
dojo.string.endsWith |
判斷輸入字符串是否以指定的字符串結(jié)尾
Usage Example:
dojo.string.endsWith("abcde", "E"); //will return false
dojo.string.endsWith("abcde", "E", true); //will return true |
dojo.string.endsWithAny |
判斷輸入字符串是否以指定的任意字符串結(jié)尾
Usage Example:
dojo.string.endsWithAny("abcde", "E", "e"); //will return true |
dojo.string.startsWith |
判斷輸入字符串是否以指定的字符串開(kāi)頭
Usage Example:
dojo.string.startsWith("abcde", "A"); //will return false
dojo.string.startsWith("abcde", "A", true); //will return true |
dojo.string.startsWithAny |
判斷輸入字符串是否以指定的任意字符串開(kāi)頭
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 |
按要求轉(zhuǎn)換回車換行的格式
Usage Example:
dojo.string.normalizeNewlines("a\r\nb\r\n", "\r"); //will return "a\rb\r" |
dojo.string.splitEscaped |
將字符串按分隔符轉(zhuǎn)換為數(shù)組
Usage Example:
dojo.string.splitEscaped("a\\_b_c", '_'); //will return ["a\\_b", "c"] |