PHP Live Regex

When creating regular expressions for PHP I tend to use the awesome tool PHP Live Regex.

This tool has really helped me over the last couple of years to create regular expressions for many of the projects I've been working on. Everything from validation functions to formatters that use regular expressions have had their expressions worked out using this tool. I even use it for testing one off expressions where I just need to find/replace in a file.

Screenshot of the PHP Live Regex tool.

The tool stands out for me as it replicates the PHP regular expressions exactly. This is in contrast to most web tools out there that do this tend to use the JavaScript regular expression library and so need some translation between the tool and your code to be able to work correctly.

PHP Live Regex works by posting the regular expression and your entered data to a PHP server that sends back the result of the regular expression. This is the reason why it is accurate to work out PHP based regular expressions using this tool. I have never had to translate the flags or syntax from this tool into a PHP application. It will also give you PHP code snippets that you can copy and paste into your code.

One word of warning is that it is probably not a good idea to use anything that you wouldn't want to be public on this tool. Due to the fact that the data is sent to an unknown server you have no control over what happens to the data beyond your request. Although the author probably has the best of intentions, the fact that you are transmitting anonymous data means you should only test the output of the tool using test data. So don't go plugging in live credit card details into it!

Since I found the PHP Live Regex tool a couple of years ago it has been a permanent bookmark and I tend to visit it every time I need to work out some complex regular expressions.

Add new comment

The content of this field is kept private and will not be shown publicly.
5 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.