MultiSwitch MultiSwitch
SEARCH
SEARCH
Converters Tools Currency Feedback

Regex Tester

Test a regular expression against your own text

Enter a pattern and some text to see every match, live.

—
Matches found
Note: uses your browser's native JavaScript regex engine. Syntax is very close to PCRE/Python but not identical — double-check patterns meant for another language.

What a regex tester is for

Regular expressions (regex) are compact patterns for finding, validating and extracting text, such as email addresses in a document, dates in a log file, or a valid postcode in a form field. They are powerful but easy to get subtly wrong, so it's worth testing a pattern against real sample text before putting it in code.

This tester runs your pattern live in your browser's JavaScript engine and lists every match. Nothing you paste is sent to a server.

Common building blocks

  • . any character except a newline · \d digit · \w letter, digit or underscore · \s whitespace
  • * zero or more · + one or more · ? optional · {2,4} between 2 and 4 times
  • [abc] any one of a, b, c · [^abc] anything except those · ^ / $ start / end of a line or string
  • ( ) capture group · (?: ) non-capturing group · a|b either a or b

Flags change how the whole pattern behaves: g finds every match, i ignores case, m makes ^ and $ match at each line, and s lets . match newlines.

Worked example

With the pattern [\w.+-]+@[\w-]+\.[\w.]+ and the g flag, the sample text returns two matches: hello@multiswitch.app and support@example.org. Remove the g flag and only the first is returned. That is the most common reason a pattern seems to “only find one”.

FAQ

Why does my pattern work here but not in Python or PHP?

This tester uses JavaScript's regex engine. Most syntax is shared, but there are differences: named groups are written differently in some languages, and certain features such as possessive quantifiers or inline modifiers aren't supported in JavaScript. Test in the target language before shipping.

How do I match a literal dot, bracket or question mark?

Escape it with a backslash: \., \[, \?. Without the backslash these characters have special meanings. A bare . matches any character.

Why is my pattern matching too much?

* and + are greedy: they grab as much text as they can. Add ? to make them lazy. For example, <.+?> matches one HTML tag at a time, where <.+> runs to the last > on the line.

Should I use regex to validate email addresses?

For a quick sanity check, yes. A simple pattern catches obvious typos. A fully standards-compliant email regex is huge and still can't prove the address exists, so the only real test is sending a confirmation email.