Preview Live Regex
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.
Try it out.
Learn how to code with Treehouse
- Learn projects with access to 1000+ videos
- Practice live with our Code Challenge Engine
- Get help in our members-only forums
- Access 100s of premium tutorials and downloadable content
- Members content consists of premium WordPress plugins
- CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
- In-depth development tutorials
- Priority tutorial requests
- No ads