aternus/stringy-patterns

A PHP string pattern detection library with multibyte support

2.0.2 2018-09-09 10:22 UTC

This package is auto-updated.

Last update: 2024-03-09 23:15:33 UTC


README

A PHP string pattern detection library with multibyte support.

use Stringy\Patterns as P;

// get all patterns
$results_array = P::create('abcdabcdab')->getPatterns();

// get all patterns, include single occurrences
$results_array = P::create('abcdabcdab')->getPatterns(true);

Why?

Patterns are all around us, perhaps you will find something useful.

Installation

If you're using Composer to manage dependencies:

composer require aternus/stringy-patterns

Then, after running composer update, you can load the class using Composer's autoloading:

require 'vendor/autoload.php';

Otherwise, you can simply require the file directly:

require_once 'vendor/aternus/stringy-patterns/src/Patterns.php';

And in either case, I'd suggest using an alias.

use Stringy\Patterns as P;

Please note that Stringy Patterns relies on the mbstring module for its underlying multibyte support. If the module is not found, and as long as you've installed Stringy Patterns using composer, Stringy Patterns will use symfony/polyfill-mbstring. For OSX users, it's a default for any version of PHP installed with homebrew. If compiling PHP from scratch, it can be included with the --enable-mbstring flag.

Other Useful Libraries

  • Stringy: A PHP string manipulation library with multibyte support

License

Released under the MIT License - see LICENSE.md for details.