The method of operation related strings

String is not an array, the method can not be mixed
1, strings and arrays can be the same, traverse
2, indexOf and lastIndexOf lookup value in a string the first and last occurrence of the subscript
3, trim trailing spaces strings removed
4, transfer of capital: to Uppercase ()
Small letter: to Lowercase ()
5, stitching and taken:
Stitching: str.concat () string splicing, return new string
Taken: str.slice (begin, end) - begin from the beginning, taken, taken to end, including begin, not including the end
  Substring (begin, end) - begin from the beginning, taken, taken to end, including begin, not including the end
Substr (begin, length) - begin from the beginning interception, the interception of length
6, split ---- string may be split into an array, the array will return a resolution obtained
You can join ---- makes up an array of strings, and returns an array of splicing resulting
7, replace replace str.replace ( "aa", "bb") the string into the first aa bb, returns the result of replacing
Want to replace all, need to use regular str.replace (/ aa / g, bb)

Guess you like

Origin www.cnblogs.com/hhmmpp/p/11070338.html