Skip to content

xp-framework/patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pattern matching

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

Regular expressions and text scanning

Example

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