DEVELOPER TOOLS / ONLINE UTILITY

PHP Regex Tester

Build and test regular expressions against sample text. Review every match, its position, and any capture groups without sending your test data to a server.

FREE ONLINE TOOL

PHP Regex Tester

Runs in your browser
JavaScript RegExp syntax is used. PHP preg_match() uses PCRE, which has some differences. Global matching is enabled automatically.
OVERVIEW

What is PHP Regex Tester?

Regular expressions describe text patterns. They are used to validate input formats, find text, extract values, and replace matching parts of a string. This browser tool uses the JavaScript RegExp engine. PHP commonly uses PCRE through preg_match() and related functions, so some syntax and features differ between the two engines.

What can you use it for?

  • Check whether a pattern matches an example string.
  • Inspect matched text, match positions, and capture groups.
  • Experiment with common flags such as case-insensitive, multiline, and dot-all.
  • Prepare and debug a pattern before adapting it to PHP PCRE syntax.

How to use this tool

  1. Enter a regular expression pattern without surrounding slash delimiters.
  2. Choose flags such as i, m, or s if needed. The tool finds all matches automatically.
  3. Paste the text to test and select Test pattern.
  4. Review the matched values, indexes, and capture groups in the output.

Example input

This pattern finds the words PHP or JavaScript. Load it, then test it against a sentence containing both terms.

\b(PHP|JavaScript)\b

Tips and things to know

  • This tool uses JavaScript regular expressions, not PHP PCRE. Check PHP documentation before copying a pattern into preg_match().
  • The pattern field does not need slash delimiters. Enter the expression only; set flags in the separate flags field.
  • The global flag is added automatically so the tool can list all matches.
  • Regular expressions are not a substitute for a dedicated parser when validating complex formats such as HTML, JSON, or programming languages.

Frequently asked questions

Does this tester use PHP preg_match()?

No. It uses the browser JavaScript RegExp engine. JavaScript and PHP PCRE share many concepts, but their syntax and supported features are not identical.

Why is the g flag added automatically?

The tool is designed to show all matches in the test text, so it uses global matching internally. You do not need to add g yourself.

Are my pattern and test text uploaded?

No. Matching is performed locally in your browser.