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
- Enter a regular expression pattern without surrounding slash delimiters.
- Choose flags such as i, m, or s if needed. The tool finds all matches automatically.
- Paste the text to test and select Test pattern.
- 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.