ShortIQ

ShortIQ

Free Developer Tool

Free Regex Tester — Test Regular Expressions Online

ShortIQ's free regex tester lets you write a regular expression, paste test text, and see matches highlighted in real time. Supports JavaScript regex syntax with global (g), case-insensitive (i), and multiline (m) flags. Useful for validating email formats, extracting data, and building search patterns.

Sponsored placement

What Is a Regular Expression?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regular expressions are used in virtually every programming language and tool to search, match, extract, replace, and validate strings. They are one of the most universally applicable tools in software development.

A regex pattern like \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b (with the case-insensitive flag) matches email addresses. The pattern \d{4}-\d{2}-\d{2} matches dates in YYYY-MM-DD format. The pattern ^https?:\/\/ matches strings that start with http:// or https://.

Regular expressions are supported in JavaScript, Python, Ruby, Java, Go, Rust, PHP, and almost every other language. Syntax varies slightly between implementations, but the core concepts are universal. This tester uses JavaScript regex syntax, which matches the behavior you would see in Node.js, browser code, and TypeScript.

  • . — matches any single character except newline
  • * — matches 0 or more of the previous character or group
  • + — matches 1 or more of the previous character or group
  • ? — makes the previous character or group optional (0 or 1)
  • \d — matches any digit (0-9)
  • \w — matches any word character (letters, digits, underscore)
  • \s — matches any whitespace character
  • ^ and $ — match the start and end of a line
  • [abc] — character class, matches a, b, or c
  • (group) — capturing group for extracting submatches

How to Use This Regex Tester

Enter your regex pattern in the pattern field (without the leading and trailing slashes). Select the flags you want to apply — g for global (find all matches instead of only the first), i for case-insensitive, and m for multiline (makes ^ and $ match line boundaries instead of the full string). Then paste your test text and the tool highlights all matches in real time.

The match list below the test text shows each match with its position and value, which is useful for understanding exactly what your pattern is capturing. If your pattern has syntax errors, the tool shows a red error message so you can fix the pattern before testing it in production code.

Common Regex Patterns Reference

These patterns solve the most common validation and extraction tasks. Copy them as starting points and adapt them to your specific requirements.

  • Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  • URL: https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z]{2,6}
  • IPv4 address: \b(?:\d{1,3}\.){3}\d{1,3}\b
  • Date YYYY-MM-DD: \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
  • Phone (US): \(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}
  • Hex color: #?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})
  • Slug: ^[a-z0-9]+(?:-[a-z0-9]+)*$

Why marketers use this tool

  • Test regex patterns without writing code or opening a terminal
  • See all matches highlighted in the test text in real time
  • Debug regex patterns faster with instant visual feedback

Frequently Asked Questions

What regex syntax does this tester use?

This tester uses JavaScript regex syntax via the built-in RegExp object. JavaScript regex is very similar to Perl-compatible regular expressions (PCRE) used by PHP and other languages, but has some differences — notably, it does not support lookbehind assertions in older versions or certain PCRE-specific features. For Python, Go, or other language-specific behavior, check the documentation for that language.

What does the g flag do?

The g (global) flag makes the regex find all matches in the test text instead of stopping after the first match. Without g, a regex only returns the first match. Enable g when you want to extract or highlight every occurrence of a pattern in a string.

What does the m flag do?

The m (multiline) flag changes the behavior of ^ and $. Without m, ^ matches only the start of the entire string and $ matches only the end. With m, ^ matches the start of each line and $ matches the end of each line. Use m when testing patterns that need to match at the beginning or end of individual lines in a multi-line string.

Why does my regex work here but not in Python?

JavaScript and Python have slightly different regex syntax and behavior. Python uses raw strings (r"pattern") to avoid double-escaping backslashes. Python's re module does not support all JavaScript flags, and some advanced features like named groups have different syntax. Test in a language-specific tool or REPL when you need exact language-matching behavior.

What is a capturing group in regex?

A capturing group is a part of the pattern wrapped in parentheses: (pattern). It captures the matched text and returns it as a separate result alongside the full match. For example, (\d{4})-(\d{2})-(\d{2}) matches a date and captures the year, month, and day as three separate groups. Non-capturing groups use (?:pattern) and group without capturing.