https://github.com/xp-framework/patterns
Pattern matching
https://github.com/xp-framework/patterns
php regex scanner xp-framework
Last synced: 2 months ago
JSON representation
Pattern matching
- Host: GitHub
- URL: https://github.com/xp-framework/patterns
- Owner: xp-framework
- Created: 2015-12-08T22:04:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-03-04T08:56:15.000Z (about 3 years ago)
- Last Synced: 2025-01-20T19:22:21.774Z (4 months ago)
- Topics: php, regex, scanner, xp-framework
- Language: PHP
- Size: 32.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
Pattern matching
================[](https://github.com/xp-framework/patterns/actions)
[](https://github.com/xp-framework/core)
[](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[](http://php.net/)
[](http://php.net/)
[](https://packagist.org/packages/xp-framework/patterns)Regular expressions and text scanning
Example
-------
```php
use text\regex\Pattern;$pattern= Pattern::compile('([w]{3}\.)?example\.(com|net|org)');
if ($pattern->matches($input)) {
// Looks like an example domain
}$result= $pattern->match($input);
$group= $result->group(0); // [ "www.example.com", "www.", "www", "com" ]
```Further reading
---------------
* [RFC #165: New text.regex package](https://github.com/xp-framework/rfc/issues/165)