Inheritance diagram for RegexIterator:

Public Member Functions | |
| __construct (Iterator $it, $regex, $mode=0, $flags=0, $preg_flags=0) | |
| accept () | |
| current () | |
| getFlags () | |
| getMode () | |
| getPregFlags () | |
| key () | |
| setFlags ($flags) | |
| setMode ($mode) | |
| setPregFlags ($preg_flags) | |
Public Attributes | |
| const | ALL_MATCHES = 2 |
| const | GET_MATCH = 1 |
| const | MATCH = 0 |
| const | REPLACE = 4 |
| const | SPLIT = 3 |
| const | USE_KEY = 0x00000001 |
Private Attributes | |
| $current | |
| $flags | |
| $key | |
| $mode | |
| $preg_flags | |
| $regex | |
Definition at line 20 of file regexiterator.inc.
| RegexIterator::__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.
| it | inner iterator | |
| regex | the regular expression to match | |
| mode | operation mode (one of self::MATCH, self::GET_MATCH, self::ALL_MATCHES, self::SPLIT) | |
| flags | special flags (self::USE_KEY) | |
| preg_flags | global PREG_* flags, see preg_match(), preg_match_all(), preg_split() |
Definition at line 52 of file regexiterator.inc.
References $flags, $it, $mode, $preg_flags, and $regex.
00052 { 00053 parent::__construct($it); 00054 $this->regex = $regex; 00055 $this->flags = $flags; 00056 $this->mode = $mode; 00057 $this->preg_flags = $preg_flags; 00058 }
| RegexIterator::accept | ( | ) |
Match current or key against regular expression using mode, flags and preg_flags.
Definition at line 68 of file regexiterator.inc.
References current(), and key().
00069 { 00070 $matches = array(); 00071 $this->key = parent::key(); 00072 $this->current = parent::current(); 00073 /* note that we use $this->current, rather than calling parent::current() */ 00074 $subject = ($this->flags & self::USE_KEY) ? $this->key : $this->current; 00075 switch($this->mode) 00076 { 00077 case self::MATCH: 00078 return preg_match($this->regex, $subject, $matches, $this->preg_flags); 00079 00080 case self::GET_MATCH: 00081 $this->current = array(); 00082 return preg_match($this->regex, $subject, $this->current, $this->preg_flags) > 0; 00083 00084 case self::ALL_MATCHES: 00085 $this->current = array(); 00086 return preg_match_all($this->regex, $subject, $this->current, $this->preg_flags) > 0; 00087 00088 case self::SPLIT: 00089 $this->current = array(); 00090 preg_split($this->regex, $subject, $this->current, $this->preg_flags) > 1; 00091 00092 case self::REPLACE: 00093 $this->current = array(); 00094 $result = preg_replace($this->regex, $this->replacement, $subject); 00095 if ($this->flags & self::USE_KEY) 00096 { 00097 $this->key = $result; 00098 } 00099 else 00100 { 00101 $this->current = $result; 00102 } 00103 } 00104 }
Here is the call graph for this function:

| RegexIterator::current | ( | ) |
Definition at line 115 of file regexiterator.inc.
Referenced by accept().
00116 { 00117 return $this->current; 00118 }
| RegexIterator::getFlags | ( | ) |
| RegexIterator::getMode | ( | ) |
| RegexIterator::getPregFlags | ( | ) |
| RegexIterator::key | ( | ) |
Definition at line 108 of file regexiterator.inc.
Referenced by accept().
00109 { 00110 return $this->key; 00111 }
| RegexIterator::setFlags | ( | $ | flags | ) |
| flags | new operaion flags |
Definition at line 143 of file regexiterator.inc.
References $flags.
00144 { 00145 $this->flags = $flags; 00146 }
| RegexIterator::setMode | ( | $ | mode | ) |
| mode | new operaion mode |
Definition at line 129 of file regexiterator.inc.
References $mode.
00130 { 00131 $this->mode = $mode; 00132 }
| RegexIterator::setPregFlags | ( | $ | preg_flags | ) |
| preg_flags | new PREG flags |
Definition at line 157 of file regexiterator.inc.
References $preg_flags.
00158 { 00159 $this->preg_flags = $preg_flags; 00160 }
RegexIterator::$current [private] |
RegexIterator::$flags [private] |
special flags (self::USE_KEY)
Definition at line 34 of file regexiterator.inc.
Referenced by __construct(), RecursiveRegexIterator::__construct(), and setFlags().
RegexIterator::$key [private] |
RegexIterator::$mode [private] |
operation mode (one of self::MATCH, self::GET_MATCH, self::ALL_MATCHES, self::SPLIT)
Definition at line 32 of file regexiterator.inc.
Referenced by __construct(), RecursiveRegexIterator::__construct(), and setMode().
RegexIterator::$preg_flags [private] |
PREG_* flags, see preg_match(), preg_match_all(), preg_split().
Definition at line 35 of file regexiterator.inc.
Referenced by __construct(), RecursiveRegexIterator::__construct(), and setPregFlags().
RegexIterator::$regex [private] |
the regular expression to match against
Definition at line 31 of file regexiterator.inc.
Referenced by __construct(), and RecursiveRegexIterator::__construct().
| const RegexIterator::ALL_MATCHES = 2 |
| const RegexIterator::GET_MATCH = 1 |
| const RegexIterator::MATCH = 0 |
| const RegexIterator::REPLACE = 4 |
| const RegexIterator::SPLIT = 3 |
| const RegexIterator::USE_KEY = 0x00000001 |
If present in $flags the the key is used rather then the current value.
Definition at line 22 of file regexiterator.inc.
1.5.2