[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Parsing/Lexer/ -> ParallelRegex.php (summary)

Lexer adapted from Simple Test: http://sourceforge.net/projects/simpletest/ For an intro to the Lexer see: https://web.archive.org/web/20120125041816/http://www.phppatterns.com/docs/develop/simple_test_lexer_notes

Author: Marcus Baker http://www.lastcraft.com
File Size: 201 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ParallelRegex:: (6 methods):
  __construct()
  addPattern()
  apply()
  split()
  getCompoundedRegex()
  getPerlMatchingFlags()


Class: ParallelRegex  - X-Ref

Compounded regular expression.

Any of the contained patterns could match and when one does it's label is returned.
__construct($case)   X-Ref
Constructor. Starts with no patterns.

param: boolean $case    True for case sensitive, false

addPattern($pattern, $label = true)   X-Ref
Adds a pattern with an optional label.

param: mixed       $pattern Perl style regex. Must be UTF-8
param: bool|string $label   Label of regex to be returned

apply($subject, &$match)   X-Ref
Attempts to match all patterns at once against a string.

return: bool|string         False if no match found, label if label exists, true if not
param: string $subject      String to match against.
param: string $match        First matched portion of

split($subject, &$split)   X-Ref
Attempts to split the string against all patterns at once

author: Christopher Smith <chris@jalakai.co.uk>
return: boolean             True on success.
param: string $subject      String to match against.
param: array $split         The split result: array containing, pre-match, match & post-match strings

getCompoundedRegex()   X-Ref
Compounds the patterns into a single
regular expression separated with the
"or" operator. Caches the regex.
Will automatically escape (, ) and / tokens.

return: null|string

getPerlMatchingFlags()   X-Ref
Accessor for perl regex mode flags to use.

return: string       Perl regex flags.