This document provides an overview of regular expressions (regex) in JavaScript. It discusses JavaScript's flavor of regex which does not support some features like word boundaries and lookbehinds. The basics of regex syntax are covered like characters, quantifiers, and character classes. Methods for using regex in JavaScript like String.replace() and RegExp.test() are listed. Examples demonstrate matching, searching, and replacing text patterns. Best practices and tools for testing regex are also mentioned.
4. Javascript’s Flavor No or anchors to match the start or end of the string. Use a caret or dollar instead. Lookbehind is not supported at all. Lookahead is fully supported. No atomic grouping or possessive quantifiers No Unicode support, except for matching single characters with No named capturing groups. Use numbered capturing groups instead. No mode modifiers to set matching options within the regular expression. No conditionals. No regular expression comments. Describe your regular expression with JavaScript // comments instead, outside the regular expression string.
5. Basics . – Matches any character, except for line breaks if dotall is false. * – Matches 0 or more of the preceding character. + – Matches 1 or more of the preceding character. ? – Preceding character is optional. Matches 0 or 1 occurrence. – Matches any single digit – Matches any word character (alphanumeric & underscore). [XYZ] – Matches any single character from the character class. [XYZ]+ – Matches one or more of any of the characters in the set. $ – Matches the end of the string. ^ – Matches the beginning of a string. [^a-z] – When inside of a character class, the ^ means NOT; in this case, match anything that is NOT a lowercase letter. {3,} – Limiting Repetition
6. Matching Modes /i makes the regex match case insensitive. /m enables "multi-line mode". /g enables "global" matching.
7. Advanced Character Classes/Sets [cat] or [^cat] [+] Capture group & Backreference (capture) (?:notcapture) Laziness & Greediness <a href=“#” title=“x”> <.*>, <[^>]*>, <.*?> Lookahead & Lookbehind (?=xxx) Unicode /00A5/.test('¥') ->true