# spatie/regex

A sane interface for php's built in preg_* functions

Repository: https://github.com/spatie/regex
Canonical: https://ross.abutalabs.com/products/spatie-regex
Homepage: https://freek.dev/549-a-package-to-easily-work-with-regex-in-php
Language: PHP
License: MIT
License Family: permissive
Topics: php, regular-expression, regex, hacktoberfest
Last push: 2026-01-31T10:29:44+00:00

## Health v2 (maintenance only)
Score: 52/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 65, release rhythm 8, longevity 100
- inputs: {"age_days": 3668, "days_push": 214, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1123, forks 49 (observed 2026-08-28T04:03:40.498150+00:00)

## What it is
A PHP library providing a clean, object-oriented wrapper around PHP's built-in preg_* regex functions. It eliminates awkward patterns like pass-by-reference parameters and inconsistent false/null error returns.

## Use cases
- match regex patterns in php without preg_* quirks
- extract capturing groups from strings
- replace text with regex callbacks
- get all regex matches in a subject
- handle no-match cases with defaults

## When to choose
- you use PHP's preg_* functions regularly and want a cleaner API
- you want exceptions instead of false/null return values
- you prefer fluent, object-oriented regex results

## When to avoid
- you need maximum performance with zero overhead
- you only use regex occasionally and raw preg_* is fine
- you're not working in PHP

## Facets
- artifact type: library
- maturity: stable
- function: parser, developer-tools
- domain: developer-tools, programming-languages
- platform: php
- tags: regex, preg, string-processing, fluent-api

## Member repositories
- spatie/regex (main) score 52

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:40.498150+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:40:53.840455+00:00, confidence not recorded.
  - readme: https://github.com/spatie/regex (fetched 2026-08-28T04:03:40.498150+00:00, sha f0391b1ec72a)
  - homepage: https://freek.dev/549-a-package-to-easily-work-with-regex-in-php (fetched 2026-08-29T12:44:18.863676+00:00, sha 4b21b6c6fa85)
  - site_page: https://freek.dev/about (fetched 2026-08-29T12:44:18.873598+00:00, sha e0ef9dccbb05)
- Data as of 2026-08-30T08:39:29.467469+00:00.
