Key Concepts
This section explains the fundamental concepts behind PHPRegex and regular expressions. Its pages sit at two altitudes: start with the foundations if the ideas are new to you, and read the deep dives when you build tooling on top of the library.
Foundations
Start here if ASTs or the visitor pattern are new to you. These two pages assume nothing and explain the data model every PHPRegex feature builds on:
- What is an AST? - The tree a pattern becomes, one node at a time
- Understanding Visitors - How one tree supports many analyses
Deep dives
These pages are written for tool authors — the people behind PHPStan extensions, linters and code generators. They assume the foundations and go into engine internals:
- PCRE vs Other Engines - Syntax by PCRE2 release, target versioning, engine comparison
- How PCRE2 Matches - Items, match attempts, backtracking and captures, read from the engine’s own traces
- ReDoS Deep Dive - Ambiguity, witnesses and the proof model
When to read these
- New to regex? Start with the main Tutorial first
- Confused about a term? Check the FAQ & Glossary
- Need deeper understanding? Read the relevant concept guide
- Building tools? Study the Architecture and Extending Guide, then the nodes, visitors and AST traversal references
Related resources
- FAQ & Glossary - Quick definitions
- Architecture - Technical deep dive
- Tutorial - Hands-on learning