Home » Php » php – Regular Expression for Dummies

php – Regular Expression for Dummies

Posted by: admin July 12, 2020 Leave a comment

Questions:

Is there any resource out there that covers regular expression in a very basic starter level? I have looked at http://www.regular-expressions.info/ but it is not exactly ‘quick reference’ friendly.. any other sources?

For me I mostly use it in php, so php friendly would be helpful.

How to&Answers:

Look at these:
http://www.webcheatsheet.com/php/regular_expressions.php
http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers

Answer:

When I was starting out with regular expressions I got recommended this book: Mastering Regular Expressions. It really helped me understand the basic concept and how regular expressions work. But also I can still learn from it today because it also covers more advanced topics.

There are some pdf versions of the books out there, but I don’t think they are legal. Otherwise I would really recommend buying this book if you really like to actually understand regexp and not just copy ready regexps and kind of understand how it works.

Answer:

If you are on windows, you can use this program http://www.radsoftware.com.au/regexdesigner/
It’s mostly for .net but can apply to any regex scenario.
There’s a quick reference on the side and you can build and test your expressions.

Answer:

Sams Teach Yourself Regular Expressions in 10 Minutes gave me a very good start. Everything about RegEx is not taught in 10 minutes but each different aspect of RegEx is broken in to easy to understand ~10 minute sessions.

To actually test RegEx’s, regexpal.com was awesome 🙂

Answer:

Here is a very basic php tutorial

You may find also some online regex testers useful, where you can play around with regular expressions.

Rubular or Regexr

Answer:

The best one I found out of these so far is http://www.addedbytes.com/download/regular-expressions-cheat-sheet-v2/png/ from Wesley Murch’s post above. I didn’t even think about searching for ‘cheat-sheet’ in google.. thanks!