deplaced / regex-simplified
A simple, customizable regex builder for PHP.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/deplaced/regex-simplified
Requires
- php: >=8.3.0
Requires (Dev)
- phpunit/phpunit: 12
This package is not auto-updated.
Last update: 2025-10-24 17:26:27 UTC
README
Regex Simplified
Simple, customizable regex builder focused on letters and numbers.
Install
composer require DePlaced/regex-simplified
Usage
use DePlaced\RegexSimplified\Regex; // Example: match uppercase-only strings $rx = Regex::make() ->start() ->uppercase() ->oneOrMore() ->end(); var_dump($rx->test('HELLO')); // true var_dump($rx->test('Hello')); // false
Examples
| Pattern | Chain | Matches | Non-matches |
|---|---|---|---|
/^[a-z]+$/u |
Regex::make()->start()->lowercase()->oneOrMore()->end() |
abc, hello |
Hello, 123 |
/^[A-Z]+$/u |
Regex::make()->start()->uppercase()->oneOrMore()->end() |
ABC, HELLO |
Hello, abc |
/^[A-Za-z]{3,5}$/u |
Regex::make()->start()->letter()->repeat(3,5)->end() |
abc, Hello |
he, toolong |
⚙️ API Reference
| Method | Description |
|---|---|
Regex::make() |
Create a new instance. |
lowercase() |
Match lowercase letters [a-z]. |
uppercase() |
Match uppercase letters [A-Z]. |
letter() |
Match any letter [A-Za-z]. |
number() |
Match digits [0-9]. |
oneOrMore() |
Quantifier +. |
repeat($min, $max = null) |
Quantifier {min,max}. |
start() |
Anchor to start ^. |
end() |
Anchor to end $. |
toPreg() |
Get the final regex string. |
test($string) |
Test a string against the built regex. |
🧩 Development
Clone your fork and install dependencies:
composer install
Run tests:
vendor/bin/phpunit
🏷️ Versioning
This project follows Semantic Versioning.
- Before
1.0.0, breaking changes may occur in minor versions (0.x.0). - After
1.0.0, breaking changes only happen in major versions.
See CHANGELOG.md for release notes.
🤝 Contributing
Pull requests and issues are welcome!
Please use Conventional Commits if possible:
feat:new featurefix:bug fixdocs:documentationtest:testschore:maintenance
📄 License
This project is open source under the MIT License.