leader

Regular Expressions

regex

View markdown

If all you have is a hammer, everything looks like a nail. -- Maslow

Regular Expressions amazing, near all-powerful hammer. But use them wisely or you will be loathed, despised, abhored, scorned when you're legacy looks like /^((http[s]?|ftp):\ /)?\/?([^:\/\ s]+)((\/\w+(*\/ )([\w\‐\.]+[ ^#?\s]+)(.*)? (#[\w\‐]+)?$/ when it could have been filter_var($url, FILTER_VALIDATE_URL) !== false.

I first started using regular expressions to search files using the Unix grep/egrep commands. Then I started modifying files from the command line with the sed command. Then I stumbled upon Perl which is excellent for text processing with built-in support for regular expressions. And then I learned PHP and was right at home with the Perl-Compatible Regular Expressions (PCRE) functions preg_match and preg_replace.

view markdown

Table of Contents

embedded

First Regex

asdfsadf asdfasdf

Second Regex