Common string methods for JS (recommended)
<SPAN style="FONT-FAMILY: 'courier new', courier">var str01 = "odd open xboxone" , str02 = "hey"; var str03; var num = 15; </SPAN>
// The first half of the "str01." is omitted below (this part is not this)
charAt(num) // Get single characters at the specified index position
charCodeAt(num) // Get the Unicode value of the character specified index position (ascii is its subset)
concat(str01,str02) // Concatenate two characters ~
indexOf("str") // Take the index of the first occurrence of str
lastIndexOf("str") // Take the index of the last occurrence of str
replace( "oldStr" , "newStr" ) // Find oldStr and replace it with newStr
slice( start , end ) // Its object can be a string or array, remember that its range does not include end
substr( start , length ) // Start from index start to take length characters, length cannot be less than 0, otherwise an empty string will be returned
search("str") // Search for string "str" in str01, return the index of its first character in str01
String.fromCharCode(uniNum,uniNum) // The parameter is Unicode value (>=1 only)
str01.localeCompare(str02) // Compare with local specific rules, if str01>str02 = 1, otherwise -1 is equal to 0
str03 = str02.valueOf() ; // Can return the original value of the string object (str02)
str03 = str01.split("str") // Split the original string into an array object, the separator is a comma, and the parameters are empty space strings
var n = num.toString() // Change Number object =>String object (n is a character), the source object has not changed
// The following are the basic style classes
<SPAN style="FONT-FAMILY: 'courier new', courier">var txt = "heyguy"</SPAN>
txt.link("url") // Convert to a hyperlink, remember to add http://
txt.big() // can be changed to big/small/bold/italic/fixed/sub/sup/strike (strike is a strikethrough)
txt.fontcolr("red") // name/rgb/#0000000 is still an old routine
txt.fontsize(num) // only supports numbers
The above is all the common JS string methods (recommended) brought to you by the editor. I hope everyone can support Wulin.com more~