JS: Regex Functions
Here is a overview of regex functions.
Best Function to Use
str.matchAll(regex)
-
Return all occurrences and captures.
str.replaceAll(regex, rep)
-
Return a new string.
Older Functions
str.search(regex)
-
Return the index of first char of the match.
str.match(regex)
-
- Return all occurrences (if regex has g flag)
- or return captured groups (if regex has no g flag).
str.replace(regex, rep)
-
Return a new string.
regex.test(str)
-
Return true/false.
regex.exec(str)
-
Return captured groups.
JavaScript. String
- JS: String Overview
- JS: Quote String
- JS: Template String
- JS: String Escape Sequence
- JS: Unicode Escape Sequence
- JS: String Operations
- JS: Iterate String
- JS: String Code Unit
- JS: Count Chars in String 📜
- JS: Tagged Template String
- JS: Regex Functions
- JS: Convert String, Number
- JS: String (class)
- JS: String Constructor
- JS: String.prototype
JavaScript. Regular Expression
- JS: RegExp Tutorial
- JS: Regex Functions
- JS: Create Regex Object
- JS: RegExp Syntax
- JS: RegExp Flag
- JS: Regex Replace String Dollar Sign
- JS: Regex Replace Function Args
- JS: RegExp (class)
- JS: RegExp Constructor
- JS: RegExp.prototype
- JS: String.prototype.search
- JS: String.prototype.match
- JS: String.prototype.matchAll
- JS: String.prototype.replace
- JS: String.prototype.replaceAll
- JS: RegExp.prototype.test
- JS: RegExp.prototype.exec