For many beginners, regular expressions seems to be hard to learn and use. In fact, they’re far less hard than you may think. Before we dive deep inside regexp with useful and reusable codes, let’s quickly see the basics:
http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers