one, provided in the stringCharAt () returns the character at the specified position.
Example: ' abc '. CHARAT (1); "B"
charCodeAt () returns the Unicode encoding of the character at the specified position.
Example: ' abc '. charCodeAt (1); 98
IndexOf (Searchvalue,fromindex) retrieves the string and returns the corresponding subscript.
Example: ' Abcabc '. IndexOf (' B ', 0); 1
' Abcabc '. IndexOf (' B ', 2); 4
Search (REGEXP) retrieves the value that matches the regular expression and returns the corresponding subscript.
Example: ' Abcabc '. Search (' B '); 1
' Abcabc '. Search (/B/IMG); 1
Match(regexp) found a match for one or more regular expressions, did not return NULL, otherwise returns an array
Example: ' Abcabc '. Match (' B '); ["B"]
' Abcabc '. Match (/B/IMG); ["B", "B"]
PS: The above regexp, can be substrings, can also be regular.
Second, RegExpDirect Volume Syntax:/pattern/attributes
Syntax for creating REGEXP objects: New REGEXP (pattern, attributes);
The regexpobject.lastindex is used to specify the starting position of the next match.
Attributes
I perform a match on case insensitive.
G performs a global match (finds all matches rather than stops after the first match is found).
M performs multi-line matching.
(1) regexpobject.exec (string) returns an array that holds the matching results, and returns NULL if it is not retrieved.
Example 1:
/c/img.exec (' ABCDEFGC '); [' C ']new RegExp ("C", "IMG"). EXEC (' ABCDEDGC '); [' C ']/c/img.exec (' a '); Null
Example 2:
var reg = new RegExp ("C", "Im"); Reg.exec ("Abcabc"); ["C"]reg.lastindex; 0var reg = new RegExp ("C", "IMG"); Reg.exec ("Abcabc"); ["C"]reg.lastindex; 0TYPEOF reg; "Object" Object.prototype.toString.call (reg); "[Object RegExp]"
(2) test retrieves the value specified in the string. Returns TRUE or FALSE.
Example:
/c/img.test (' ABCDEFGC '); Truenew RegExp ("C", "IMG"). Test (' ABCDEDGC '); True
JavaScript: Find/Match