HTML
stringObject.split(separator, length); 用於把字串分隔成「字串陣列」,separator 為分隔字串 length 為分隔數目)。 separator("") 那麼 字元 之間都會被分割。 separator(" ") 那麼 字串 之間都會被分割。 stringObject 中的每個字元之間都會被分割。 "ug5g com : script : split()!".split("") = "ug5g com : script : split()!".split("",10) = "ug5g com : script split()!".split(/\s+/) = "ug5g com : script : split()!".split(/\s+/,3) = "ug5g com : script : split()!".split(" ") = "ug5g com : script : split()!".split(" ",13) = "ug5g com : script : split()!".split(":",13) =
stringObject.replace(regexp, replaceString) 字串取代符合 regexp 部份被 replaceString 部份取代, 可加 /g 代表總體尋找,可加 /i 代表不分大小寫。 "As As as As".regexp(/As/,"XX") = "As As as As".regexp(/As/g,"XX") = "As As as As".regexp(/As/gi,"XX") =
stringObject.match(regexp, replaceString) 傳回尋「找到的字串」regexp 為待尋找的字串, 可加 /g 代表總體尋找,可加 /i 代表不分大小寫。 "As As as As".match(/As/,"XX") = "As As as As".match(/As/g,"XX") = "As As as As".match(/As/gi,"XX") =
stringObject.concat(stringX,stringX,...,stringX) 將數過 字串 混合順序連接到字串 。 var TxT = "0123456789ABCDEF" TxT.concat("B11","C11","D11") =
"to string method".toUpperCase() =
"TO STRING METHOD".toLowerCase() =
沒有留言:
張貼留言