Regular Expression Testing

Online test and validate regular expressions, supports real-time matching, replacement function, and common regular expression examples.

Matching Results

Found 0 matches

Common Regular Expression Reference

Email Address
^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$
Phone Number
^1[3-9]\d{9}$
URL
^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$
IPv4 Address
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
ID Number
^[1-9]\d{5}(?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}[\dXx]$
Password Strength
^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$

Regular Expression Syntax Reference

Character Classes

. Match any character (except newline)
\d Match numbers [0-9]
\w Match letters, numbers, and underscores [A-Za-z0-9_]
\s Match whitespace characters (space, tab, newline)

Quantifiers

* Match 0 or more times
+ Match 1 or more times
? Match 0 or 1 time
{n} Match exactly n times

Boundaries

^ Match start of line
$ Match end of line
\b Match word boundary

Regular Expression Guide

Learn how to write and test regular expressions effectively.

What are regular expressions used for?

  • Text Validation:
    • Email and phone number formats
    • Password strength requirements
    • Input field validation
  • Text Processing:
    • Search and replace operations
    • Data extraction from text
    • Pattern matching in strings

How to use regex flags?

  • Global (g): Match all occurrences in text
  • Case Insensitive (i): Ignore letter case
  • Multiline (m): Match start/end of each line
  • Unicode (u): Enable full Unicode matching

Testing Best Practices

  • Start Simple: Begin with basic patterns and build up
  • Test Edge Cases: Include boundary conditions
  • Use Groups: Organize complex patterns with ()
  • Escape Special Characters: Use \ for literals like . * + ?