Regex Tester

Common regex (click to fill):

What Is a Regex Tester?

A regular expression (regex) is a small language that uses a set of special characters to match, find, and extract text that fits a pattern. This tool lets you test regex online: enter a pattern and test text, see every match highlighted instantly, along with capture groups and indexes. It also ships with 17 common regex quick presets (Chinese characters, email, URL, phone, QQ, postal code, ID card, dates, and various integers/floats) for fast verification and copying.

Basic regex syntax

  • Character classes: [abc] matches a/b/c, [^abc] negates, [a-z] is a range
  • Predefined characters: \d digit, \w word char, \s whitespace, . any char except newline
  • Quantifiers: * 0+, + 1+, ? 0 or 1, {n,m} n to m times
  • Anchors: ^ start, $ end, \b word boundary
  • Groups and logic: (...) capture group, (?:...) non-capturing, | or
  • Common flags: g global, i case-insensitive, m multiline, s dot matches newline

Common regex examples

  • Match Chinese characters: [\u4e00-\u9fa5]
  • Match email: [\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}
  • Match URL: [a-zA-Z]+://[^\s]*
  • Match phone number: \d{3}-\d{8}|\d{4}-\d{7}
  • Match 18-digit ID: \d{17}[\dXx]|\d{15}
  • Match date: \d{4}-\d{1,2}-\d{1,2}
  • Match positive integer: [1-9]\d*
  • Match positive float: [1-9]\d*\.\d*|0\.\d*[1-9]\d*

How to use

  1. Click a common regex preset above, or enter a pattern and flags manually
  2. Enter or paste the text you want to test
  3. Click "Test" to view highlighted matches, capture groups, and indexes; use the "Regex Code Generator" page to produce code in your language