I love making my own tools for the simple and mundane tasks I face during the day. One of those tasks is the repeated need for testing regular expressions that I am faced with when programming. Yes, there are a multitude of regular expression testers on the web today, and all of them have a laundry list of cool things they do. But none of them are mine, and none of them are necessarily simple. And few of them let you see how they work. So with that, I decided to take one of the many tools I’ve built for myself and offer it here for you.
My (very) simple regular expression is just that… a simple tester that takes a regular expression and a subject string and gives you back your matches as PHP would see them in your application. There is one small bit of robustness (I had to use robustness… the word is just so cool) added to this tester that will allow you to group your matches together (
PREG_SET_ORDER) and allow you to include the string position of the match in the subject (
PREG_OFFSET_CAPTURE). But that is where the robustness ends the simple kicks in again.
So if you want a simple little regular expression tester, or just want to see how I’ve coded mine, feel free to use my tester for your own needs. Have fun, stay curious and GO BIG.