js字符串操作与例子(国外英文资料).doc
文本预览下载声明
js字符串操作与例子(国外英文资料)
Concat () - combines two or more characters together to return a new string.
IndexOf () - returns the index that appears in the first substring in the string. If there is no match, return -1.
CharAt () - returns the character of the specified location.
LastIndexOf () - returns the index of the last occurrence of a substring in a string, and returns -1 if there is no match.
Match () - checks whether a string matches a regular expression.
Substring () - a substring that returns a string. The incoming parameter is the start and end position.
Replace () - used to find a string that matches a regular expression, and then replace the matched string with the new string.
Search () - performs a regular expression matching lookup. If the lookup is successful, return the indexed value in the string. Otherwise return -1.
Slice () - extracts part of the string and returns a new string.
Split () - by dividing a string into substrings, a string is made into an array of strings.
Length - the length of a string, the length of a string is the number of characters it contains.
ToLowerCase () - turns the entire string into lowercase letters.
ToUpperCase () - turns the entire string into a capital letter.
/ *
* * * * * * * * * * * * *
The string function expands
* * * * * * * * * * * * *
* /
/ *
For example, this is the case for the problem
/ / remove the space on the left
For example, this is the case for the problem
* /
String. Prototype. LTrim = function ()
{
Return this. The replace (/ (^ \ s *)/g, );
}
/ *
For example, this is the case for the problem
/ / remove the space on the right
For example, this is the case for the problem
* /
String. Prototype. Rtrim = function ()
{
Return this. Replace (/ (s * $)/g, );
}
/ *
For example, this is the case for the problem
/ / remove the space before and after
For example, this is the case for the problem
* /
().trim = function ()
{
Return this. The replace (/ (^ \ s *) | (\ s * $)/g, );
}
/ *
For example, this is the case
显示全部