RegexIterator::__construct() - 迭代器
RegexIterator::__construct()
(PHP 5 >= 5.2.0, PHP 7)
Create a new RegexIterator
说明
publicRegexIterator::__construct(Iterator$iterator, string $regex[,int $mode= self::MATCH[,int $flags= 0[,int $preg_flags= 0]]])Create a new RegexIterator which filters an Iterator using a regular expression.
参数
$iteratorThe iterator to apply this regex filter to.
$regexThe regular expression to match.
$modeOperation mode, see RegexIterator::setMode() for a list of modes.
$flagsSpecial flags, see RegexIterator::setFlags() for a list of available flags.
$preg_flagsThe regular expression flags. These flags depend on the operation mode parameter:
operation mode | available flags |
---|---|
RegexIterator::ALL_MATCHES | See preg_match_all(). |
RegexIterator::GET_MATCH | See preg_match(). |
RegexIterator::MATCH | See preg_match(). |
RegexIterator::REPLACE | none. |
RegexIterator::SPLIT | See preg_split(). |
错误/异常
Throws an InvalidArgumentException if the $regex argument is invalid.
范例
RegexIterator::__construct() example
Creates a new RegexIterator that filters all strings that start with 'test'.
以上例程的输出类似于:
test 1 test 123
参见
preg_match()
执行匹配正则表达式preg_match_all()
执行一个全局正则表达式匹配preg_replace()
执行一个正则表达式的搜索和替换preg_split()
通过一个正则表达式分隔字符串
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!