SoFunction
Updated on 2025-03-10

js string operation function

concat() – combines two or more characters' text and returns a new string.
indexOf() – Returns the index that appears at the first place of a substring in the string. If there is no match, return -1.
charAt() – Returns the character at the specified position.
lastIndexOf() – Returns the index that appears at the last place of a substring in the string. If there is no match, return -1.
match() – Checks whether a string matches a regular expression.
substring() – Returns a substring of the string. The incoming parameters are the start position and the end position.
replace() – Used to find a string that matches a regular expression and then use a new string instead of the matching string.
search() – Performs a regular expression matching lookup. If the search is successful, return the matching index value in the string. Otherwise, return -1.
slice() – Extracts part of the string and returns a new string.
split() – Make a string into an array of strings by dividing them into substrings.
length – Returns the length of a string. The so-called length of a string refers to the number of characters it contains.
toLowerCase() – Converts the entire string to lowercase letters.
toUpperCase() – Converts the entire string to capital letters.