Regex Tester

Results

Common patterns

Email

\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b

Spanish mobile number (example)

(?:\+34|0034|34)?[6789][0-9]{8}

URL

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

IP Address

\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b

Date (format only)

\b\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}\b

Decimal number

-?\d+(?:\.\d+)?

Regex fundamentals

Regular expressions describe text patterns. Understanding the building blocks helps you craft accurate expressions that are easy to debug.

Core syntax

  • . matches any character except newline, \d digits, \w word characters, \s whitespace.
  • Character classes [abc] match specific sets; use [^abc] to negate.
  • Anchors ^ and $ ensure matches start or end at specific positions.
  • Quantifiers (*, +, ?, {m,n}) control repetition.

Flags

  • g finds all matches; i ignores case.
  • m treats input as multiline, making ^/$ match line boundaries.
  • s lets . match newlines; u enables Unicode support.
  • y (sticky) attempts matches starting at the last index in JavaScript engines.

Best practices

Thoughtful patterns are easier to maintain and less likely to cause performance surprises.

Document intent

Use verbose mode ((?x)) or inline comments to explain non-obvious groups and avoid future mistakes.

Avoid catastrophic backtracking

Limit nested wildcards, prefer explicit quantifiers, and consider atomic/possessive groups to guard against exponential runtime.

Validate beyond regex

Combine pattern checks with schema or business rules—especially for emails, URLs, and structured identifiers.

Compare a simple pattern in JavaScript and Python

These examples return two matches: 123-45-6789 and 987-65-4321. Matching a numeric shape does not validate an identifier. More complex patterns can behave differently between engines.

JavaScript

const pattern = /\b\d{3}-\d{2}-\d{4}\b/g;
const matches = 'Visit 123-45-6789 or 987-65-4321'.match(pattern) ?? [];
console.log(matches);

Python

import re

pattern = re.compile(r'\b\d{3}-\d{2}-\d{4}\b')
text = 'Visit 123-45-6789 or 987-65-4321'
print(pattern.findall(text))

Regex tester FAQ

What are common regex flags and what do they do?

Flags such as g, i, m, s, and u adjust matching behavior—use them to find multiple results, ignore case, work with multiline input, or enable Unicode.

How can I avoid catastrophic backtracking?

Avoid nested quantifiers and broad alternatives that can match the same input in many ways. Use short test samples and bounded patterns. This tester uses the JavaScript engine; atomic groups and possessive quantifiers from other engines are not supported.

Does this regex tester send my sample text to a server?

No. Testing happens entirely in your browser so log snippets, payloads, and secrets remain private.

When should I use lookaheads or lookbehinds?

Use lookarounds to assert surrounding context without consuming characters—helpful for password policies, boundary checks, or format validation.

What is the best way to validate email addresses with regex?

A shape check can catch obvious input mistakes, but matching does not prove that a mailbox exists or belongs to the user. Use a confirmation email when ownership matters.

Choose a developer tool

More tools for data, text and testing

Run the AES interoperability guide or read how these tools are checked.