PHP Class ParallelRegex, simpletest

Any of the contained patterns could match and when one does, it's label is returned.
Mostra file Open project: simpletest/simpletest Class Usage Examples

Public Methods

Method Description
__construct ( boolean $case ) Constructor. Starts with no patterns.
addPattern ( string $pattern, string $label = true ) Adds a pattern with an optional label.
match ( string $subject, string &$match ) : boolean Attempts to match all patterns at once against a string.

Protected Methods

Method Description
getCompoundedRegex ( ) Compounds the patterns into a single regular expression separated with the "or" operator.
getPerlMatchingFlags ( ) : string Accessor for perl regex mode flags to use.

Method Details

__construct() public method

Constructor. Starts with no patterns.
public __construct ( boolean $case )
$case boolean True for case sensitive, false for insensitive.

addPattern() public method

Adds a pattern with an optional label.
public addPattern ( string $pattern, string $label = true )
$pattern string Perl style regex, but ( and ) lose the usual meaning.
$label string Label of regex to be returned on a match.

getCompoundedRegex() protected method

Caches the regex. Will automatically escape (, ) and / tokens.
protected getCompoundedRegex ( )

getPerlMatchingFlags() protected method

Accessor for perl regex mode flags to use.
protected getPerlMatchingFlags ( ) : string
return string Perl regex flags.

match() public method

Attempts to match all patterns at once against a string.
public match ( string $subject, string &$match ) : boolean
$subject string String to match against.
$match string First matched portion of subject.
return boolean True on success.