To match or not to match with regular expressions in PHP
Published April 05, 2016
One of the most important tools in any programming language is regular expressions, because it searches for patterns in strings.
Where regular expressions can be used? Almost everywhere. For form validation, browser detection, spam filtering, to check the strength of passwords, and so much more.
This tutorial will explain the subject from the perspective of the PHP programmer.
- How to find matching strings?
- The i modifier
- Global regular expression matching
- Meta what? Metacharacter!
- The problem of string literals
- Character sets
- Shorthand character sets
- Qunantifiers in regular expressions
- Lazy and greedy expressions
- How to find a match to set of expressions?
- How to match alternatives when the order does matter?
- Capturing groups and backreferences
- The search for strings that don't match
- Search and replace with preg_replace
- How to split strings by regular expressions?
- How to search for matches inside arrays?
- Where to go from here?
Learn to use regular expressions in PHP.