Regex Tester - DigiKitApp

Test a regular expression pattern against text.

When should you use this?

Use this when you need to test live whether a regular expression you've written actually matches the text you expect.

When shouldn't you use this?

If a simple "contains" or "starts with" check is enough, using your programming language's built-in text functions instead of writing regex is more readable and faster.

Step-by-step

  1. Type your pattern into the Regex pattern field. Leave out the surrounding slashes and enter only the pattern itself, for example \d{5} for a five-digit postal code.
  2. If needed, add letters to Flags (optional): g to find every match, i to ignore case, m to treat each line separately.
  3. Paste real sample data into Test text. Include lines that should match and lines that should not, so you can see both sides.
  4. Click Run and read the result. If something matches that shouldn't, adjust the pattern in small steps and run it again.

Example

Say you're pulling phone numbers out of a customer export. Some are written as 0532 123 45 67, others as 05321234567. Enter 0?5\d{2}\s?\d{3}\s?\d{2}\s?\d{2} as the pattern with the g flag and you'll see right away whether both formats are caught. Add a landline that starts with 4 to the test text as well. If it doesn't match, you know the pattern isn't too loose.

What is a regular expression (regex)?

A regular expression is a short language for describing a pattern in text. For example \d+ means one or more digits, ^ the start of a line, $ the end of a line, [A-Z] an uppercase letter, . any character, and * and + repetition. Parentheses are for grouping and capturing, | for alternatives. Regex is very useful for form validation, search-and-replace and data extraction.

Tips for writing regex

  • Start with a small sample text and extend the pattern step by step.
  • Mind the difference between greedy (*, +) and lazy (*?, +?) repetition; many unexpected matches come from this.
  • Regex engines differ slightly; the tool uses your browser's JavaScript engine.
  • Instead of trying to fully validate complex formats like email or URL with one regex, use a well-known library.

Things to keep in mind

  • Regex flavors differ between languages. A pattern that works here may behave differently in Python, PHP or a database engine, so test it once in the target environment too.
  • Dots, plus signs, question marks and brackets have special meaning. To match them literally, put a backslash in front.
  • Star and plus are greedy by default and grab as much text as they can. Use the lazy form, such as .*?, when you want the shortest match between two markers.
  • Shortcuts like \w don't always include accented or non-Latin letters. If your text has them, spell out the character class yourself.

Frequently asked questions

Is the code/data I enter stored anywhere?

No, nothing is sent to a server or stored; processing happens entirely in your browser.

Does it work with large inputs?

Yes, though performance may degrade with very large inputs (several MB or more).

Is this tool free?

Yes, it's completely free for core use and requires no account.