Regex Syntax Fundamentals
Learn character classes, quantifiers, anchors, and groups in PCRE.
What is a Regular Expression?
A regular expression (regex) is a pattern that describes a set of strings. PHP uses the PCRE (Perl-Compatible Regular Expressions) engine.
Delimiters
PHP regex patterns are enclosed in delimiters — commonly /, but you can also use # if the pattern contains slashes.
<?php
$pattern = '/hello/i'; // case-insensitive
$pattern2 = '#https?://#'; // # avoids escaping /All lessons in this course
- Regex Syntax Fundamentals
- Matching with preg_match
- Replacing Text with preg_replace
- Splitting and Practical Patterns