var str = "abc123def666";
// charAt() 方法返回字符串中指定位置的字符。
// 參數:index
// console.log(str.charAt(6)); // d
// indexOf() 方法返回 指定值 在字符串對象中首次出現的位置。
// 從 fromIndex 位置開始查找,如果不存在,則返回 -1。
// 注意:區分大小寫
// console.log(str.indexOf("123")); // 3
// console.log(str.indexOf("123", 2)); // 3
// 正則方法
// search
// 執行一個查找,看該字符串對象與一個正則表達式是否匹配。
// console.log(str.search("1")); // 3
// console.log(str.search(/[0-9]/)); // 3
// replace
// 被用來在正則表達式和字符串直接比較,然后用新的子串來替換被匹配的子串。
// console.log(str.replace("1", "-one-"));
// console.log(str.replace(/\d/, "-one-"));
// match
// 當字符串匹配到正則表達式(regular expression)時,
// match() 方法會提取匹配項。
// console.log(str.match(/\d+/)); // ["123", index: 3, input: "abc123def666"]
// split
// 通過把字符串分割成子字符串來把一個 String 對象分割成一個字符串數組。
// console.log(str.split("1")); // ["abc", "23def666"]
// slice
// 提取字符串中的一部分,並返回這個新的字符串
// 獲取索引號為1,2,3的字符串,即[1, 4)
// console.log(str.slice(1, 4)); // bc1
// substr
// 方法返回字符串中從指定位置開始到指定長度的子字符串。
// 開始位置 和 長度
// console.log(str.substr(3, 3)); // 123
// substring
// 返回字符串兩個索引之間(或到字符串末尾)的子串。
// 開始位置 和 結束位置
// console.log(str.substring(3, 6)); // 123
// trim()
// 刪除一個字符串兩端的空白字符
// str = " abc123 def666 ";
// console.log("|" + str.trim() + "|"); // |abc123 def666|
// toLowerCase()
// 將調用該方法的字符串值轉為小寫形式,並返回。
// console.log(str.toLowerCase()); // abc123def666
// toUpperCase()
// 將字符串轉換成大寫並返回。
// console.log(str.toUpperCase()); // ABC123DEF666
