Tool Launcher

Search for a tool...

1tt.dev1tt.dev
Regex Tester
//
0 chars
Enter a pattern to see matches

What is a Regular Expression?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regex patterns can match simple strings, complex character sequences, and structured formats like email addresses or URLs. They are supported natively in virtually every programming language and are a standard tool for text processing, validation, and data extraction.

A regex is written as a pattern enclosed in delimiters — for example /\d+/g — where the part between slashes is the pattern and the trailing letters are flags that modify matching behavior.

How Regex Works

The regex engine scans a string character by character and attempts to match the pattern at each position. Special syntax controls how matching behaves:

  • Character classes like \d, \w, [a-z] match sets of characters.
  • Quantifiers like *, +, {n,m} control how many times a token is matched.
  • Anchors like ^ and $ assert a position rather than matching a character.
  • Capture groups wrapped in () extract sub-matches and enable back-references in replacements via $1, $2, etc.
  • Flags like g (global), i (case-insensitive), and m (multiline) change engine behavior.

How to Use This Tool

  • Enter a pattern in the regex field — matches update live as you type.
  • Toggle flags with the clickable badge buttons next to the pattern field.
  • Load a common pattern from the Patterns dropdown to quickly test email, URL, IPv4, date, and other common formats.
  • Click a match in the Matches panel to expand its start/end indices and capture group values.
  • Enable Replace Mode to preview the result of a substitution using $1 back-references.
  • Switch the Code tab between JS, Python, and Go to generate a ready-to-use snippet.
  • Open the Cheat Sheet for a quick reference of syntax — click any item to insert it into the pattern field.
  • Share the current regex, flags, and test string via a URL hash link.

Common Use Cases

  • Validating user input — [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} for email addresses.
  • Extracting structured data from logs — matching timestamps, error codes, or IP addresses with capture groups.
  • Find-and-replace in editors like VS Code and JetBrains IDEs, both of which use $1 back-reference syntax.
  • Parsing version strings using a pattern like (\d+)\.(\d+)\.(\d+) to capture major, minor, and patch components.
  • Stripping HTML tags from a string using <[^>]+> with the global flag.
  • Tokenizing source code or config files during build tooling or linting pipelines.