53 parent::__construct($it);
71 $this->
key = parent::key();
72 $this->
current = parent::current();
74 $subject = ($this->flags & self::USE_KEY) ? $this->
key : $this->
current;
78 return preg_match($this->regex, $subject, $matches, $this->preg_flags);
82 return preg_match($this->regex, $subject, $this->
current, $this->preg_flags) > 0;
84 case self::ALL_MATCHES:
86 return preg_match_all($this->regex, $subject, $this->
current, $this->preg_flags) > 0;
90 preg_split($this->regex, $subject, $this->
current, $this->preg_flags) > 1;
94 $result = preg_replace($this->regex, $this->replacement, $subject);
95 if ($this->flags & self::USE_KEY)
$flags
special flags (self::USE_KEY)
accept()
Match current or key against regular expression using mode, flags and preg_flags. ...
const ALL_MATCHES
Mode: Return all matches (if any)
setPregFlags($preg_flags)
const USE_KEY
If present in $flags the key is used rather then the current value.
$regex
the regular expression to match against
const MATCH
Mode: Executed a plain match only.
Abstract filter for iterators.
const SPLIT
Mode: Return the split values (if any)
const GET_MATCH
Mode: Return the first matche (if any)
Regular expression filter for iterators.
$mode
operation mode (one of self::MATCH, self::GET_MATCH, self::ALL_MATCHES, self::SPLIT) ...
const REPLACE
Mode: Replace the input key or current.
$preg_flags
PREG_* flags, see preg_match(), preg_match_all(), preg_split()
$key
the value used for key()
$current
the value used for current()
__construct(Iterator $it, $regex, $mode=0, $flags=0, $preg_flags=0)
Constructs a regular expression filter around an iterator whose elemnts or keys are strings...