HTML5 Zone is brought to you in partnership with:

Paulund is a website dedicated to writing tutorials and code snippets about Web Development, the main subjects are PHP, Wordpress, jQuery, CSS3 and HTML5. Paul is a DZone MVB and is not an employee of DZone and has posted 137 posts at DZone. You can read more from them at their website. View Full User Profile

Preview Live Regex

  • submit to reddit

Regular expressions are a great way to find a pattern of text to do a global replace or to store the variables of the pattern. The problem comes when you have quite a complicated pattern that you are trying to match. You might need to make lots of changes to your code for it to work correctly. This continued code changes and re-testing your code can be very time consuming, you need a better way of testing your regular expressions.

If you are creating a htaccess file to match URLs and redirect else where then you need a good way of testing the pattern.

Here is a really good tool for testing regular expressions, it's called PHP Live Regex and allows you to test matching your regex with a number of different strings. If you are using the preg_match() function then this tool will even provide you with an array of matches you will get from this regular expression.

Once you have finished your regex to match the strings you want, you can save this code by creating a URL for this regex code. Which makes this tool really useful for code sharing, if you have created a regex and want to share this with other developers you can do so with a simple link.

PHP Live Regex

Try it out.

PHP Live Regex

Published at DZone with permission of Paul Underwood, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)