cvs: php-src /ext/spl/internal regexiterator.inc
| From: | Marcus Boerger | Date: | Thu, 20 Jul 2006 22:04:52 +0000 |
| Subject: | cvs: php-src /ext/spl/internal regexiterator.inc | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-39411@lists.php.net to get a copy of this message | ||
helly Thu Jul 20 22:04:52 2006 UTC
Modified files:
/php-src/ext/spl/internal regexiterator.inc
Log:
- Update docu
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/internal/regexiterator.inc?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/spl/internal/regexiterator.inc
diff -u php-src/ext/spl/internal/regexiterator.inc:1.4
php-src/ext/spl/internal/regexiterator.inc:1.5
--- php-src/ext/spl/internal/regexiterator.inc:1.4 Thu Jul 20 21:21:20 2006
+++ php-src/ext/spl/internal/regexiterator.inc Thu Jul 20 22:04:52 2006
@@ -34,6 +34,7 @@
self::GET_MATCH, self::ALL_MATCHES, self::SPLIT) */
private $preg_flags;/**< PREG_* flags, see preg_match(), preg_match_all(),
preg_split() */
+ private $key; /**< the value used for key() */
private $current; /**< the value used for current() */
/**
@@ -67,9 +68,10 @@
function accept()
{
$matches = array();
+ $this->key = parent::key();
$this->current = parent::current();
/* note that we use $this->current, rather than calling parent::current() */
- $subject = ($this->flags & self::USE_KEY) ? parent::key() : $this->current;
+ $subject = ($this->flags & self::USE_KEY) ? $this->key : $this->current;
switch($this->mode)
{
case self::MATCH:
@@ -86,9 +88,28 @@
case self::SPLIT:
$this->current = array();
preg_split($this->regex, $subject, $this->current, $this->preg_flags) > 1;
+
+ case self::REPLACE:
+ $this->current = array();
+ $result = preg_replace($this->regex, $this->replacement, $subject);
+ if ($this->flags & self::USE_KEY)
+ {
+ $this->key = $result;
+ }
+ else
+ {
+ $this->current = $result;
+ }
}
}
+ /** @return the key after accept has been called
+ */
+ function key()
+ {
+ return $this->key;
+ }
+
/** @return the current value after accept has been called
*/
function current()