0PricingLogin
PHP Academy · Lesson

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

  1. Regex Syntax Fundamentals
  2. Matching with preg_match
  3. Replacing Text with preg_replace
  4. Splitting and Practical Patterns
← Back to PHP Academy