The RegexIterator class

Introduction

This iterator can be used to filter another iterator based on a regular expression.

Class synopsis

RegexIterator
extends FilterIterator
/* Constants */
public const int RegexIterator::USE_KEY;
public const int RegexIterator::INVERT_MATCH;
public const int RegexIterator::MATCH;
public const int RegexIterator::GET_MATCH;
public const int RegexIterator::ALL_MATCHES;
public const int RegexIterator::SPLIT;
public const int RegexIterator::REPLACE;
/* Properties */
public stringnull $replacement = null;
/* Methods */
public RegexIterator::__construct(
    Iterator $iterator,
    string $pattern,
    int $mode = RegexIterator::MATCH,
    int $flags = 0,
    int $pregFlags = 0
)
public bool RegexIterator::accept()
public int RegexIterator::getFlags()
public int RegexIterator::getMode()
public int RegexIterator::getPregFlags()
public string RegexIterator::getRegex()
public void RegexIterator::setFlags(int $flags)
public void RegexIterator::setMode(int $mode)
public void RegexIterator::setPregFlags(int $pregFlags)
/* Inherited methods */
public bool accept()
public mixed current()
public mixed key()
public void next()
public void rewind()
public bool valid()
public mixed IteratorIterator::current()
public Iteratornull IteratorIterator::getInnerIterator()
public mixed IteratorIterator::key()
public void IteratorIterator::next()
public void IteratorIterator::rewind()
public bool IteratorIterator::valid()

Predefined Constants

RegexIterator operation modes

RegexIterator::ALL_MATCHES

Return all matches for the current entry (see preg_match_all).

RegexIterator::GET_MATCH

Return the first match for the current entry (see preg_match).

RegexIterator::MATCH

Only execute match (filter) for the current entry (see preg_match).

RegexIterator::REPLACE

Replace the current entry (see preg_replace; Not fully implemented yet)

RegexIterator::SPLIT

Returns the split values for the current entry (see preg_split).

RegexIterator Flags

RegexIterator::USE_KEY

Special flag: Match the entry key instead of the entry value.

RegexIterator::INVERT_MATCH

Inverts the return value of RegexIterator::accept.

Properties

replacement

Table of Contents