To minimize writing chunks, of code regular expressions can save a heap of work. The downside to this, is that sometimes they can be hard to read, build or test.
To save more time in building and testing your regular expression use a Regular Expression tester. An online regular expression tester that I use often is this one. Does pretty much everything you would need. Test out your regular expressions quickly before using them in any of your favorite scripting or programming languages.