2017 © Pedro Peláez
 

library wildcards

A simple wildcard matcher

image

rkr/wildcards

A simple wildcard matcher

  • Sunday, April 26, 2015
  • by rkr
  • Repository
  • 5 Watchers
  • 8 Stars
  • 321 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 6 Versions
  • 11 % Grown

The README.md

Simple wildcard component (PHP 5.3+)

Build Status Scrutinizer Code Quality, (*1)

This project aims to provide a dead simple component for php to support wildcards. Wildcards are * (zero or more character) and ? (exactly one character). The component is not tied to filenames. You can use it also for namespaces, urls and other strings., (*2)

Why can't you just provide a simple function for this?

Because of effectivity. When you create an instance of the Pattern-class, you also "compile" the pattern. This means that I try to find the optimal test method for your later input. So if you run the same pattern more often in the same run, you could benefit from that optimization. If not, the Interface should still be simple enough to make you happy. If not, go wrap a function around it., (*3)

Why not just use regular expressions?

Because there is no reason to use regular expressions for the most common figures:, (*4)

string* means "starts with".
*string means "ends with"., (*5)

So even if I use regular expressions to cover complex patterns, it is too pointless to use regular expressions for one of these. Internally I use substr() instead. If you like to provide more speedups for such simple patterns, feel free to push me some., (*6)

Composer:

composer require rkr/wildcards ^1.0

Example:

<?php
use Kir\StringUtils\Matching\Wildcards\Pattern;

(new Pattern('test.*'))->match('test.txt');      // true
Pattern::create('test.*')->match('test.txt');    // true
Pattern::create('*.txt')->match('test.txt');     // true
Pattern::create('*.*')->match('test.txt');       // true
Pattern::create('test*txt')->match('test.txt');  // true
Pattern::create('test?txt')->match('test.txt');  // true
Pattern::create('t*.???')->match('test.txt');    // true
Pattern::create('t*t?.txt')->match('test8.txt'); // true

The Versions

26/04 2015

dev-master

9999999-dev http://github.com/rkrx/wildcards

A simple wildcard matcher

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

The Development Requires

by Ronald Kirschler

wildcards wildcard

19/09 2014

1.0.3

1.0.3.0 http://github.com/rkrx/wildcards

A simple wildcard matcher

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

The Development Requires

by Ronald Kirschler

wildcards wildcard

17/11 2013

1.0.1

1.0.1.0 http://github.com/rkrx/wildcards

A simple wildcard matcher

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

The Development Requires

by Ron

wildcards wildcard

17/11 2013

1.0.2

1.0.2.0 http://github.com/rkrx/wildcards

A simple wildcard matcher

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

The Development Requires

by Ron

wildcards wildcard

16/11 2013

v0.0.1

0.0.1.0 http://github.com/rkrx/wildcards

A simple wildcard matcher

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

The Development Requires

by Ron

wildcards wildcard

16/11 2013

1.0.0

1.0.0.0 http://github.com/rkrx/wildcards

A simple wildcard matcher

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

The Development Requires

by Ron

wildcards wildcard