RegexIterator
class RegexIterator extends FilterIterator (View source)
This iterator can be used to filter another iterator based on a regular expression.
Constants
ALL_MATCHES |
Return all matches for the current entry preg_match_all |
GET_MATCH |
Return the first match for the current entry preg_match |
MATCH |
Only execute match (filter) for the current entry preg_match |
REPLACE |
Replace the current entry (Not fully implemented yet) preg_replace |
SPLIT |
Returns the split values for the current entry preg_split |
USE_KEY |
Special flag: Match the entry key instead of the entry value. |
INVERT_MATCH |
|
Properties
$replacement |
Methods
Create a new RegexIterator
Get accept status
Returns operation mode.
Sets the operation mode.
Get flags
Sets the flags.
Returns current regular expression
Returns the regular expression flags.
Sets the regular expression flags.
Details
__construct(Traversable $iterator, string $pattern, int $mode = self::MATCH, int $flags = 0, int $pregFlags = 0)
Create a new RegexIterator
Iterator|null
getInnerIterator()
Get the inner iterator
void
rewind()
Rewind the iterator
bool
valid()
Check whether the current element is valid
mixed
key()
Get the current key
mixed
current()
Get the current element value
void
next()
Move the iterator forward
bool
accept()
Get accept status
int
getMode()
Returns operation mode.
void
setMode(int $mode)
Sets the operation mode.
int
getFlags()
Get flags
void
setFlags(int $flags)
Sets the flags.
string
getRegex()
Returns current regular expression
int
getPregFlags()
Returns the regular expression flags.
void
setPregFlags(int $pregFlags)
Sets the regular expression flags.