Back
正则表达式在线测试工具
正则表达式
/
/g
标志位:
常用正则:
测试文本
匹配结果

请输入正则表达式

Regex Tester Online

Introduction

The Online Regex Tester is a free, browser-based regular expression debugging and validation platform designed for developers, data analysts, and QA engineers. Powered by the JavaScript RegExp engine, it provides real-time match highlighting, capture group extraction, five flag toggles, and instant syntax error feedback. With 143 built-in templates spanning network addresses, contact information, identity documents, financial data, developer tools, color formats, naming conventions, and more, you can populate a regex pattern with a single click. All computation runs entirely within your browser — no data is ever transmitted to a server, ensuring complete privacy and security.

Core Features

Real-time Matching and Highlighting

As you type your regex pattern and test text, the tool immediately computes matches without requiring a manual trigger. Matches are highlighted directly within the original text and simultaneously displayed in a sortable table showing each match's value, precise character position, and index. Capture group contents are broken out in a dedicated column, making it easy to debug complex regex patterns with multiple parenthetical groups.

Five Flag Toggles

All five standard JavaScript RegExp flags are supported with individual toggle switches:
  • Global (g): Find all matches in the text rather than stopping at the first match
  • Ignore Case (i): Perform case-insensitive matching
  • Multiline (m): Make ^ and $ anchors match the start and end of each line
  • Dot All (s): Allow . to match all characters including newline (\n)
  • Unicode (u): Enable full Unicode matching support with proper surrogate pair handling

143 Built-in Regex Templates

The tool includes 143 regex templates organized by domain. Click any template button to instantly populate the regex pattern field:
Network & Communication: URL, IPv4/IPv6 addresses, domain name, port number, CIDR notation, private IP, loopback IP, FTP URL, magnet URI, MAC address, E.164 international phone
Contact & Identity: Email address, phone number, landline, ID card number, Chinese name, US SSN, Hong Kong ID, Korean RRN, Singapore NRIC, Japanese My Number, Brazilian CPF, Indian PAN, Canadian SIN, UK NI number, French SIREN, Australian TFN, unified social credit code
Financial & Payment: Bank card number, Visa, MasterCard, American Express, UnionPay, IBAN, German IBAN, currency amount, SWIFT/BIC code, CVV security code, ABA routing number
Developer Tools: UUID, semantic versioning, Base64 string, JWT token, MD5 hash, SHA-256 hash, Bcrypt hash, Git commit hash, HTML tag, HTML comment, XML tag, CSS unit, Data URI, PEM certificate, SSH public key, Cookie string, Cron expression
Color Formats: Hexadecimal color (3 or 6 digit), RGB color, HSL color
Barcodes & Identifiers: ISBN-10, ISBN-13, EAN-13, UPC-A, IMEI number, ULID, Nano ID
Cryptocurrency & Web3: Bitcoin address, Ethereum address, Solana address, Ethereum transaction hash, IPFS CID
Naming Conventions: camelCase, snakecase, PascalCase, kebab-case
Text & Character Processing: Chinese characters, Hiragana, Katakana, Korean characters, Emoji, whitespace, blank lines, line endings, quoted strings, double spaces, leading/trailing spaces
Package Management & Repositories: npm package name, npm scoped package, GitHub repository path, Java package name
Cloud Services: AWS ARN, S3 URL, Docker image name
Geocoding & Standards: US state abbreviation, US ZIP code, UK postcode, Canadian postal code, latitude/longitude coordinates, ISO country code (2-letter), currency code (ISO 4217), language code (ISO 639-1)
Social Media & Media: Twitter/X handle, hashtag, YouTube URL, Markdown image, Markdown link
Academics & Publishing: DOI identifier, ORCID researcher ID, ISSN journal number, ISBN book number

Real-time Syntax Error Detection

When the entered regex pattern contains a syntax error, the tool immediately displays a detailed error message, helping you quickly identify and fix issues before they make it into your codebase.

Operations & Monitoring

Templates for Sentry DSN, Google Analytics tracking ID, log levels (TRACE/DEBUG/INFO/WARN/ERROR/FATAL), and HTTP methods (GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS/CONNECT/TRACE).

Use Cases

  • Frontend Form Validation: Write and debug regex validation rules for form fields such as email format, phone numbers, and password strength requirements
  • Backend Data Extraction: Build regex patterns to extract structured information from logs, API responses, configuration files, and other text-based data sources
  • Data Cleaning & Transformation: Batch process text data — remove extra whitespace, standardize date formats, extract numeric values, and more
  • Code Search & Refactoring: Craft regex patterns to search for specific patterns across codebases, assisting with code review and large-scale refactoring
  • Security Auditing: Detect SQL injection and XSS attack patterns in logs, or validate sensitive data formats
  • Learning Regular Expressions: Visual match results and instant feedback help beginners quickly master regex syntax through hands-on experimentation

Tips

  1. Start from a template closest to your needs, then modify it incrementally
  2. Combine flags strategically — enabling both Global and Ignore Case simultaneously can surface more matches
  3. Pay attention to the Capture Groups column to verify that parenthetical groups are extracting the intended content
  4. The Position column shows character index positions, making it easy to locate matches in your source code

Notes

  • This tool uses the JavaScript RegExp engine, which has subtle differences from PCRE (PHP), re (Python), and other regex engines
  • Lookbehind assertions may not be supported in older browsers; use a modern, up-to-date browser for the best experience
  • All data and computation remain entirely within your browser — nothing is uploaded or stored on any server