php-standard-library/regex
Type-safe regex for PHP with typed capture groups and predictable error handling. Build expressions with confidence, get structured match results, and avoid silent failures common in preg_* functions. Part of PHP Standard Library.
preg_* calls into a cleaner, more maintainable API.preg_match’s null/false ambiguity).Illuminate\Validation) and parsing workflows.Adopt if:
preg_* syntax errors, edge cases (e.g., preg_last_error()), or inconsistent return handling.Validator::extend()).Look elsewhere if:
StringUtil, league/html-to-markdown) that handles regex internally.preg_* calls that would require significant refactoring to adopt."This lightweight PHP package standardizes regex usage across our codebase, reducing bugs and improving maintainability—especially in validation and parsing. By wrapping raw preg_* calls in a safer, fluent API, we cut repetitive boilerplate and make text-processing logic easier to debug. It’s a low-risk, high-reward investment for teams handling user input, logs, or structured data. Think of it as ‘Laravel’s built-in regex helper,’ but open-source and dependency-light."
Key Ask:
*"This package solves three critical problems:
preg_* pitfalls (e.g., silent failures, unclear return values) with structured methods like Regex::test(), Regex::extract().preg_match snippets.Regex::replace()->pattern('/.../')->with('...') are self-documenting.Proposal:
preg_* calls with this wrapper in new PRs.Trade-offs:
How can I help you explore Laravel packages today?