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 · 4/5

BasicsMoreGroupsQuantifiers
. 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

Check a list of values against one regex

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 gives you the formats to match, and 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

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:

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

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.

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.