diff options
| author | Marcus Boerger <helly@php.net> | 2006-07-16 19:16:40 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2006-07-16 19:16:40 +0000 |
| commit | 0499e0d8f1fa9ae043b3c3a86e6263d9e23ab7a4 (patch) | |
| tree | 143088d31d7ad08875589e9d605127e6f65f038d /ext/spl/internal/regexiterator.inc | |
| parent | 4aa20e0781d1a764b4069be2e972aac949106b57 (diff) | |
| download | php-git-0499e0d8f1fa9ae043b3c3a86e6263d9e23ab7a4.tar.gz | |
- Update docu
Diffstat (limited to 'ext/spl/internal/regexiterator.inc')
| -rwxr-xr-x | ext/spl/internal/regexiterator.inc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/ext/spl/internal/regexiterator.inc b/ext/spl/internal/regexiterator.inc new file mode 100755 index 0000000000..02dd4836ae --- /dev/null +++ b/ext/spl/internal/regexiterator.inc @@ -0,0 +1,51 @@ +<?php + +/** @file regexiterator.inc + * @ingroup SPL + * @brief class RegexIterator + * @author Marcus Boerger + * @date 2003 - 2006 + * + * SPL - Standard PHP Library + */ + +/** + * @brief Regular expression filter for iterators + * @author Marcus Boerger + * @version 1.0 + * @since PHP 5.1 + * + * This filter iterator assumes that the inner iterator + */ +class RegexIterator implements FilterIterator +{ + const USE_KEY = 0x00000001; + + private $regex; /**< the regular expression to match against */ + private $flags; /**< special flags (USE_KEY) */ + + /** + * Constructs a regular expression filter around an iterator whose + * elemnts or keys are strings. + * + * @param it Object that implements at least + */ + function __construct(Iterator $it, $regex, $flags = 0) { + parent::__construct($it); + $this->regex = $regex; + $this->flags = $flags; + } + + /** + * Match current or key against regular expression. + * + * @return whether this is a match + */ + function accept() + { + $subject = ($this->flags & self::USE_KEY) ? parent::key() : parent::current(); + return preg_match($this->regex, $subject); + } +} + +?>
\ No newline at end of file |
