Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xp-framework/patterns
Pattern matching
https://github.com/xp-framework/patterns
php regex scanner xp-framework
Last synced: about 1 month ago
JSON representation
Pattern matching
- Host: GitHub
- URL: https://github.com/xp-framework/patterns
- Owner: xp-framework
- Created: 2015-12-08T22:04:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-03-04T08:56:15.000Z (almost 3 years ago)
- Last Synced: 2024-08-10T10:09:26.642Z (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
================[![Build status on GitHub](https://github.com/xp-framework/patterns/workflows/Tests/badge.svg)](https://github.com/xp-framework/patterns/actions)
[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)
[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)
[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)
[![Latest Stable Version](https://poser.pugx.org/xp-framework/patterns/version.png)](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)