Tools & Templates

# Regex checker and tester online: free, instant

Paste a pattern, type a value, and see what matches as you type: the matched text, each capture group, and the error when the pattern is not valid. Free, no sign-up, nothing leaves your browser. It uses JavaScript syntax, the one Google Tag Manager triggers use; GA4 filters accept the same patterns without lookarounds and backreferences. Below, check a whole list of values against one regex at once.

Reviewed by **[David Pombar](/author/david-pombar)** ·  4/5

| Basics | More | Groups | Quantifiers |
| --- | --- | --- | --- |
| `.` Any non-newline character | `\n` New line | `*` 0 or more | `(...)` Capturing group |
| `\s` Any whitespace character | `\t` Tab | `+` 1 or more | `(?:...)` Non-capturing group |
| `\d` Any digit | `[abd]` Characters a, b, or c | `?` 0 or 1 | `(a\|b)` Match a or b |
| `^` Start of line | `[^abd]` Any characters except a, b, or c | `{2}` Exactly 2 | `(...)?` Optional match group |
| `$` End of line | `[a-z]` Any character a to z | `{3,6}` Between 3 and 6 | `(\d\d)` Match any two digits |
| `\` Character Escape | `[a-zA-Z]` Any character a to z OR A to Z | `{4,}` 4 or more | `(amy)` Match word 'amy' |

## How to use

**Type your regex** in the pattern field, with flags such as `i` or `g` if you need them. The field turns red and shows the error when the syntax is not valid.  
**Type up to three values.** Each turns green when the pattern matches and red when it does not.  
**Read the match details** under the fields: the matched text highlighted in each value, and every capture group with its content.  
**Checking many values?** Paste the whole list in the batch check further down.

## Regex checker: test a pattern as you type

Regex pattern. Green: is a valid pattern. Red: Is not a valid pattern.Strings to validate. Green: The pattern matches the value. Red: The pattern does not match the value.Flags Optional: i (ignore case), g (all matches), m (multiline), s, u.

## Check a list of values against one regex

Regex pattern

Validate →

That is the whole tool: a pattern, your values, a green or red answer for each one, and what matched. If the syntax is the problem, the guide below goes from a literal match to groups, quantifiers and anchors.

If you are writing patterns to find personal data in your analytics, the [list of PII examples by category](/blog/list-of-personally-identifiable-information) gives you the formats to match, and [what is PII](/faqs/what-is-pii) explains which of them matter for compliance.

## Frequently asked questions

?How do I check if a regex pattern is valid?

tp

Type it in the pattern field above. If the pattern compiles, the field turns green; if not, it turns red and the error says why, for example an unclosed group or a quantifier with nothing to repeat.

?What regex syntax does this checker use?

tp

JavaScript, the syntax Google Tag Manager uses in its triggers and variables. GA4 filters accept the same patterns except lookarounds and backreferences, so a pattern that uses them works here but not in GA4.

?What is the difference between test() and match() in JavaScript?

tp

`regex.test(text)` returns true or false: whether the pattern matches anywhere in the text. `text.match(regex)` returns what matched: the matched text and its capture groups, or every match when the pattern has the `g` flag. This page uses both: the colour is test(), the match details are match().

?Is my data sent anywhere?

tp

No. The pattern and the values are checked in your browser, and nothing leaves the page.

## How to Write a Regex: A Comprehensive Guide to Regular Expressions

Regular expressions, or regex, are a powerful tool for searching, matching, and manipulating text. Whether you're a developer working with JavaScript, a data scientist parsing datasets, or simply someone looking to refine search patterns, understanding how to write effective regex can significantly enhance your productivity. This guide will walk you through the basics of creating regular expressions, from simple matches to complex patterns.

### Understanding the Basics of Regex

At its core, a regex is a string of characters used to define a search pattern. It can be used for everything from validating email addresses and phone numbers to parsing large text files. Regex patterns are supported by many programming languages, including JavaScript (JS), Python, and PHP, making them a versatile skill for any coder.

### Starting with Simple Patterns

-   **Literal Characters:** The simplest form of regex is a sequence of literal characters, such as ** `test`**, which will match the exact string "test" in your search text.
-   **Metacharacters:** To unlock the full potential of regex, you'll need to use metacharacters. Characters like ** `.`** (dot) match any single character, while ** `*`** (asterisk) matches zero or more of the preceding element.

### Using Character Classes

Character classes allow you to match any one out of several characters at a specific position. For example, **`[abc]`** will match any single character a, b, or c. Use ranges to match any character within a range, such as ** `[a-z]`** for any lowercase letter.

### Implementing Quantifiers

Quantifiers let you specify how many instances of a character or group you want to match:

-   **`?`** matches 0 or 1 of the preceding element, making it optional.
-   **`+`** matches 1 or more of the preceding element.
-   **`{n}`** matches exactly n occurrences of the preceding element.

### Grouping and Capturing

Parentheses **`()`** are used to group parts of your regex together. This not only allows you to apply quantifiers to the entire group but also lets you capture the matched text for use later.

### Advanced Techniques

-   **Lookahead and Lookbehind:** These constructs let you assert what does or doesn't follow or precede your match without including it in the result.
-   **Non-Capturing Groups:** ** `(?:...)`** groups part of your regex without capturing the matched text.
-   **Flags:** Regex flags like ** `g`** (global search), ** `i`** (case-insensitive), and ** `m`** (multi-line) modify how the search is performed.

### Tips for Writing Effective Regex

1.  **Start Simple:** Begin with the basics and gradually add complexity.
2.  **Use Online Regex Testers:** Tools like online regex testers are invaluable for experimenting with and debugging your expressions.
3.  **Keep Learning:** Regular expressions are a deep topic. Explore more advanced patterns and techniques as you grow more comfortable.

### Conclusion

Writing regex is a skill that combines logic, precision, and a bit of creativity. By starting with the fundamentals and progressively tackling more complex patterns, you can harness the full power of regular expressions to make your text processing tasks more efficient and effective. Remember, practice makes perfect, so use online regex testers and validators to refine your skills and ensure your expressions are error-free.

On this page

1.  [*01*How to use](#how-to-use)
2.  [*02*Regex checker: test a pattern as you type](#regex-checker-test-a-pattern-as-you-type)
3.  [*03*Check a list of values against one regex](#check-a-list-of-values-against-one-regex)
4.  [*04*Frequently asked questions](#frequently-asked-questions)
5.  [*05*How to Write a Regex: A Comprehensive Guide to Regular Expressions](#how-to-write-a-regex-a-comprehensive-guide-to-regular-expressions)

**Stop babysitting tags**

Trackingplan audits your real user data around the clock and flags issues before they cost you.

[Start free trial →](https://app.trackingplan.com/signup)

Trackingplan

## See everything. Miss nothing.

Your implementations audited around the clock with real-time, real-user data. Real-time alerts about errors or changes in your data, campaigns, pixels, privacy and consent. Let AI flag issues before they cost you.

[Start free trial →](https://app.trackingplan.com/signup) [Book a demo](/demo)
