DevToolbox
All tools
Developer tools

Regex Tester

Test, validate, and debug JavaScript regular expressions with real-time match indexing and flag controls.

Designed for local browser processing

Only test patterns you understand on inputs you trust. Extremely complex patterns can cause slow matching on large text.

What Is a Regular Expression (Regex)?

A regular expression (regex) is a sequence of characters that forms a search pattern. In software engineering, regular expressions are essential for validating form inputs (such as emails or telephone numbers), extracting structured substrings from logs, and performing complex text search-and-replace operations.

Common Regular Expression Flags Explained

  • g (Global): Searches for all matches throughout the text rather than stopping after the first occurrence.
  • i (Case-Insensitive): Ignores uppercase vs. lowercase distinctions during matching.
  • m (Multiline): Treats the beginning (^) and end ($) anchors as matching the start and end of each individual line, rather than the entire input string.
  • s (DotAll): Allows the wildcard dot (.) to match newline characters as well.
  • u (Unicode): Enables full Unicode pattern matching and surrogate pair support.

Essential Regex Cheatsheet

  • \d: Matches any digit (equivalent to [0-9]).
  • \w: Matches any word character (alphanumeric plus underscore).
  • \s: Matches whitespace characters (spaces, tabs, newlines).
  • +: Matches one or more repetitions of the preceding token.
  • *: Matches zero or more repetitions.
  • ?: Matches zero or one repetition (makes matches optional or lazy).
  • [abc]: Character class matching any character inside the brackets.
  • (abc): Capturing group.

Security Reminder: Catastrophic Backtracking (ReDoS)

Be cautious when nesting quantifiers like (a+)+ against adversarial inputs. Complex, non-deterministic regular expressions can cause exponential execution times known as Regular Expression Denial of Service (ReDoS). Always test your patterns against varied edge-case inputs.

Read the technical guide: Regular Expressions for Beginners

Explore more free developer tools