Regex Methodology & Tokens

Regular expressions (Regex) are patterns used to match character combinations in strings. Our tester uses the JavaScript RegExp engine.

Common Tokens

  • \d: Matches any digit (0-9).
  • \w: Matches any word character (alphanumeric + underscore).
  • \s: Matches any whitespace character (spaces, tabs).
  • .: Matches any character except line breaks.
  • ^: Matches the beginning of the string.
  • $: Matches the end of the string.
  • *: Matches 0 or more of the preceding token.
  • +: Matches 1 or more of the preceding token.
  • ?: Matches 0 or 1 of the preceding token.
  • [abc]: Matches any character in the set.
  • (abc): Groups multiple tokens together and creates a capture group.

Flags

  • g (global): Don't return after the first match.
  • i (insensitive): Case-insensitive matching.
  • m (multiline): ^ and $ match start/end of lines.
  • s (single line): Dot matches newline.