NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the FAQ
for more details.
I used to hate regular expressions, however, recently I've had a need to use them a fair amount so actually started to appreciate them. What I found challenging then was debugging them. Writing code, compiling it and executing it just to find out the regex was incorrect was not going anywhere fast, so I looked around and found Reggy.app
. This very simple app lets you put in your test strings and most importantly, your regex and see what matches. It's a super handy tool.
There are other tools out there for this kind of thing, but I find Reggy is just so simple and lightweight that it's become my regex debugging tool of choice.
Best of all, Reggy lets you see what is matching visually. The matches are highlighted for you so there is no second-guessing of what works and what doesn't.
So far I didn't really answer whether you should or should not regex, well that depends - it depends on whether regular expressions are really what your code requires, sometimes a simple string comparison is all that's needed. It's really up to you to decide, with great power [or regex], comes great responsibility :)
Hope you found this post useful...
...so please read on! I love writing articles that provide beneficial information,
tips and examples to my readers. All information on my blog is provided free of
charge and I encourage you to share it as you wish. There is a small favour I ask in return however -
engage in comments below, provide feedback, and if you see mistakes let me know.
If you want to show additional support and help me pay for web hosting and
domain name registration,
donations, no matter how small, are always welcome!
Use of any information contained in this blog post/article is subject to this disclaimer
Other posts you may like...