RegularExpression
extends Filter
in package
Class \Hoa\Iterator\RegularExpression.
Re-implement the SPL RegexIterator class. There are too many bugs in php-src and HHVM, so we re-implement it from scratch without extending the existing class.
Inspired by hhvm://hphp/system/php/spl/iterators/RegexIterator.php
Tags
Table of Contents
Constants
- ALL_MATCHES = 2
- Mode and preg flag: all matches for the current entry.
- GET_MATCH = 1
- Mode and preg flag: first match for the current entry.
- INVERT_MATCH = 2
- Flag: invert match.
- MATCH = 0
- Mode and preg flag: only execute match (filter) for the current entry.
- REPLACE = 4
- Mode and preg flag: replace the current entry.
- SPLIT = 3
- Mode and preg flag: split values for the current entry.
- USE_KEY = 1
- Flag: match the entry key instead of the entry value.
Properties
- $replacement : string
- Replacement.
- $_current : string
- Current value.
- $_flags : int
- Special flags, see the \RegexIterator::setFlag method for a list of available flags.
- $_key : int
- Current key.
- $_mode : int
- Operation mode, see the \RegexIterator::setMode method for a list of modes.
- $_pregFlags : int
- The regular expression flags. See constants.
- $_regex : string
- The regular expression to match.
Methods
- __construct() : mixed
- Constructor.
- accept() : bool
- Get accept status.
- current() : string
- Get current value.
- getFlags() : int
- Get flags.
- getMode() : int
- Get mode.
- getPregFlags() : int
- Get preg flags.
- getRegex() : string
- Get regular expression.
- key() : int
- Get current key.
- setFlags() : void
- Set flags.
- setMode() : void
- Set mode.
- setPregFlags() : void
- Set preg flags.
Constants
ALL_MATCHES
Mode and preg flag: all matches for the current entry.
public
mixed
ALL_MATCHES
= 2
Tags
GET_MATCH
Mode and preg flag: first match for the current entry.
public
mixed
GET_MATCH
= 1
Tags
INVERT_MATCH
Flag: invert match.
public
mixed
INVERT_MATCH
= 2
Tags
MATCH
Mode and preg flag: only execute match (filter) for the current entry.
public
mixed
MATCH
= 0
Tags
REPLACE
Mode and preg flag: replace the current entry.
public
mixed
REPLACE
= 4
Tags
SPLIT
Mode and preg flag: split values for the current entry.
public
mixed
SPLIT
= 3
Tags
USE_KEY
Flag: match the entry key instead of the entry value.
public
mixed
USE_KEY
= 1
Tags
Properties
$replacement
Replacement.
public
string
$replacement
= null
$_current
Current value.
protected
string
$_current
= null
$_flags
Special flags, see the \RegexIterator::setFlag method for a list of available flags.
protected
int
$_flags
= 0
$_key
Current key.
protected
int
$_key
= 0
$_mode
Operation mode, see the \RegexIterator::setMode method for a list of modes.
protected
int
$_mode
= 0
$_pregFlags
The regular expression flags. See constants.
protected
int
$_pregFlags
= 0
$_regex
The regular expression to match.
protected
string
$_regex
= null
Methods
__construct()
Constructor.
public
__construct(RecursiveIterator $iterator, string $regex[, int $mode = self::MATCH ][, int $flags = 0 ][, int $pregFlags = 0 ]) : mixed
Parameters
- $iterator : RecursiveIterator
-
The recursive iterator to apply this regex filter to.
- $regex : string
-
The regular expression to match.
- $mode : int = self::MATCH
-
Operation mode, please see the \RegexIterator::setMode method.
- $flags : int = 0
-
Special flags, please see the \RegexIterator::setFlags method.
- $pregFlags : int = 0
-
Regular expression flags, please see \RegexIterator constants.
accept()
Get accept status.
public
accept() : bool
Return values
boolcurrent()
Get current value.
public
current() : string
Return values
stringgetFlags()
Get flags.
public
getFlags() : int
Return values
intgetMode()
Get mode.
public
getMode() : int
Return values
intgetPregFlags()
Get preg flags.
public
getPregFlags() : int
Return values
intgetRegex()
Get regular expression.
public
getRegex() : string
Return values
stringkey()
Get current key.
public
key() : int
Return values
intsetFlags()
Set flags.
public
setFlags(int $flags) : void
Parameters
- $flags : int
-
Flags.
setMode()
Set mode.
public
setMode(int $mode) : void
Parameters
- $mode : int
-
Mode.
setPregFlags()
Set preg flags.
public
setPregFlags(int $pregFlags) : void
Parameters
- $pregFlags : int
-
Preg flags.