https://github.com/themarlboroman/php-pattern-matcher
Simple class to match strings
https://github.com/themarlboroman/php-pattern-matcher
match parameter php string
Last synced: 12 months ago
JSON representation
Simple class to match strings
- Host: GitHub
- URL: https://github.com/themarlboroman/php-pattern-matcher
- Owner: TheMarlboroMan
- License: mit
- Created: 2018-06-10T20:17:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-22T07:57:00.000Z (almost 3 years ago)
- Last Synced: 2025-01-11T11:26:42.501Z (about 1 year ago)
- Topics: match, parameter, php, string
- Language: PHP
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-pattern-matcher
Simple class to match strings
# what is this
It matches strings against strings and allows for a level of parametrization, say
this_is_my/[value:int]/and_something_[other_value:alpha]/else
Can be matched to "this_is_my/33/and_something_word/else" in a way in which a match would exist and two values would be parametrized: 33 and "word".
# so... like regular expressions?
But slower. And with less features.
# then... why?
I needed something like this for a router and it had to fulfill a these requirements:
- The pattern syntax needed to be really easy and homogeneous.
- The people who would use it needed to be able to extend, debug and follow the code along.
# would I want to use this, how would I do it?
Check the examples directory. There are a couple of examples there that will show you how to match strings and extract parameters.