Proficient in using regular expressions requires understanding the purpose of each special character, flag, and method. This quick lookup table summarizes the usage of JavaScript regular expressions, which is convenient for you to check at any time.
var regex = new RegExp('\u{61}', 'u'); console.log(regex.unicode); // true
lastIndex
property indicates the starting position of the search.[Back to top]
Brackets are used for grouping. Sub-patterns can be formed using match()
and replace()
methods.
split()
method
The split()
method allows you to split the main string into substrings based on the delimiter specified as a regular expression.
var texta = 'This 593 string will be broken294en at places where d1gits are.'; var regexone = /\d /g // Output: ["This", " string will be broken", "en at places where d", "gits are."] console.log(texta.split(regexone))
[Back to top]
Previous tutorials have covered the basics of regular expressions, as well as some more complex expressions that can be very useful occasionally. These two tutorials explain how different characters or sequences of characters work in regular expressions.
The above is the detailed content of JavaScript Regex Cheat Sheet. For more information, please follow other related articles on the PHP Chinese website!