JS: Regular Expression Functions
Here is a overview of regex functions.
Do All Occurrences
str.matchAll(regex)-
Return all occurrences and captures.
str.replaceAll(regex, rep)-
Return a new string.
Do First (or All)
str.search(regex)-
Return the index of first char of the match.
str.match(regex)-
- If regex has g flag → return all occurrences
- If regex has no g flag → return captured groups.
- If regex has no g flag nor capture → return first match.
str.replace(regex, rep)-
Replace first occurrence (or all). Return a new string.
Return just boolean
regex.test(str)-
Return true/false.
Get captured groups, or
regex.exec(str)-
Return captured groups.
JavaScript. String
- JS: String Overview
- JS: Quote String
- JS: Apostrophe Delimiter 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: Regular Expression Functions
- JS: Convert String and Number
- JS: String (class)
- JS: String Constructor
- JS: String.prototype
JavaScript. Regular Expression
- JS: Regular Expression Tutorial
- JS: Regular Expression Functions
- JS: Create Regex Object
- JS: Regular Expression Syntax
- JS: Regular Expression Flags
- 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