JavaScript regular expressions

JavaScript regex, RegExp patterns, and string matching

Learn JavaScript regular expressions with focused lessons on RegExp syntax, flags, character classes, anchors, quantifiers, groups, backreferences, alternation, lookahead, lookbehind, sticky search, and string methods.

Regular expression lessons and concepts

  1. RegExp patterns and flags

    Start with JavaScript regular expression literals, constructor syntax, flags, and practical matching behavior.

    Outcome: Read and write basic JavaScript RegExp patterns with the right flags.

    • JavaScript regex
    • RegExp JavaScript
    • regular expression flags
    Study Patterns and flags
  2. Character classes and Unicode

    Match digits, words, whitespace, Unicode categories, and escaped characters across JavaScript strings.

    Outcome: Build patterns that match characters precisely instead of relying on broad dots.

    • regex character classes
    • Unicode regex
    • JavaScript \p property
    Study Character classes
  3. Anchors and word boundaries

    Use start, end, multiline anchors, and word boundaries to control where a regex match can occur.

    Outcome: Constrain matches to exact positions in strings and lines.

    • regex anchors
    • word boundary regex
    • multiline regex
    Study Anchors: string start ^ and end $
  4. Sets, ranges, and escaping

    Combine character sets, ranges, and escaping rules so punctuation and special characters match correctly.

    Outcome: Write reliable character-level patterns without accidental metacharacter bugs.

    • regex sets
    • regex ranges
    • escape regex JavaScript
    Study Sets and ranges [...]
  5. Quantifiers and greedy matching

    Understand plus, star, question mark, ranges, greedy matching, lazy matching, and backtracking risks.

    Outcome: Control repetition and avoid patterns that become slow on real input.

    • regex quantifiers
    • greedy lazy regex
    • catastrophic backtracking
    Study Quantifiers +, *, ? and {n}
  6. Capturing groups and backreferences

    Capture substrings, name groups, reuse previous matches, and organize complex JavaScript regexes.

    Outcome: Extract and reuse parts of a match with groups and backreferences.

    • regex groups
    • named capture groups
    • regex backreferences
    Study Capturing groups
  7. Alternation, lookahead, and lookbehind

    Use OR patterns, positive and negative assertions, and advanced conditional matching.

    Outcome: Match context without always consuming text.

    • regex alternation
    • regex lookahead
    • regex lookbehind
    Study Alternation (OR) |
  8. RegExp and String methods

    Apply JavaScript regexes with match, matchAll, search, replace, split, test, exec, and sticky scanning.

    Outcome: Use JavaScript RegExp patterns in everyday string processing code.

    • RegExp methods
    • String match replace
    • sticky regex
    Study Methods of RegExp and String