
A regular expression (regex or regexp) is a sequence of characters that forms a search pattern, mainly for use in pattern matching with strings, or string matching, like in “find and replace” operations.
The regular expressions are extremely useful in searching, replacing or extracting information from text such as code, log files, spreadsheets, or even documents.
1: Introduction to Regular Expressions
Here Derek Banas explains how Regular Expressions are used. He cover all of the codes and what they are used for. The goal is to teach you how to use regular expressions once and for all.
The RegEx Cheat Sheet
abc… | Letters |
123… | Digits |
\d | any Digit |
. | any Character |
\. | Period |
[abc] | Only a, b, or c |
[^abc] | Not a, b, nor c |
[a-z] | Characters a to z |
[0-9] | Numbers 0 to 9 |
{m} | m Repetitions |
{m,n} | m to n Repetitions |
* | Zero or more repetitions |
+ | One or more repetitions |
? | Optional |
\s | any Whitespace |
^…$ | Starts and ends |
() | capture Group |
(a(bc)) | capture Sub group |
(.*) | capture Variable content |
(a|b) | Matchs a or b |
\w | any Alphanumeric character |
\W | any Non-alphanumeric character |
\d | any Digit |
\D | any Non-digit character |
\s | any Whitespace |
\S | any Non-whitespace character |
2: /Reg(exp){2}lained/: Demystifying Regular Expressions
Quick, what does this do: /(\/\*?\\/)|\/\/.*?(\r?\n|$)/g? If you’re like many developers, you just averted your eyes, and your heart is now in your throat. Symptoms included sweaty palms and recurring nightmares with blood-thirsty ASCII symbols. But don’t worry, this condition doesn’t have to be chronic. A cure is right around the corner.
As with many developers, you’re familiar with the power of regular expressions, but anything beyond the basics scares the crap out of you. Fear no more young padawan! In this talk, we’ll start with the basics and progressively enhance your knowledge until you’re coding regular expressions like a champ. Everything will be demonstrated live with visual examples that ensure maximum comprehension.
3: Regular Expressions in Python
In this videos Derek Banas shows how to use Regular Expressions in Python and provide many more examples how to search for numerous different types of data, output and manipulate that data.
4: Regular Expressions in Javascript
In this tutorial Derek Banas shows how to use Regular Expressions in Javascript to make form validation.
5: Regular Expressions in PHP
In this videos Derek Banas shows how to use Regular Expressions with PHP to find email addresses, phone numbers, valid passwords, and many more things.
Derek Banas also shows you how to grab disorganized information from a web page and also cover many other functions in PHP like: preg_match_all, fgets, strstr, preg_replace, and more.
Best Regular Expressions Book:
Instructors: Derek Banas and Lea Verou
Price: Free