本文整理匯總了PHP中Regex::MetaPregMatchEx方法的典型用法代碼示例。如果您正苦於以下問題:PHP Regex::MetaPregMatchEx方法的具體用法?PHP Regex::MetaPregMatchEx怎麽用?PHP Regex::MetaPregMatchEx使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Regex
的用法示例。
在下文中一共展示了Regex::MetaPregMatchEx方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: foreach
foreach ($matches as $match) {
echo "Regex::Matches ( {$match[0]}, {$match[1]} ) = " . (Regex::Matches($match[0], $match[1]) ? 'true' : 'false') . $eol;
}
echo $eol;
// DevelopExpression() example
$expressions = ['file[0-9].txt', 'file[a-c][0-2].bin'];
foreach ($expressions as $expression) {
echo "Regex::DevelopExpression ( {$expression} ) = {$eol}{$tab}";
$developed_expressions = Regex::DevelopExpression($expression);
echo rtrim(str_replace("\n", "{$eol}{$tab}", print_r($developed_expressions, true)));
echo "{$eol}";
}
echo $eol;
// PregMatchEx() example
$subject = "a:1 b:2";
$re = '/(?P<sequence> (?P<letter> [a-z]) : (?P<digit> [0-9])) \\s (?P<sequence> (?P<letter> [a-z]) : (?P<digit> [0-9]))/imsx';
echo "Regex::PregMatchEx ( {$subject}, {$re}, WIPE ) : ";
$result = Regex::PregMatchEx($re, $subject, $match, PREG_WIPE_MATCHES | PREG_OFFSET_CAPTURE);
echo "\t" . str_replace("\n", "{$eol}{$tab}", print_r($match, true));
echo $eol;
echo "Regex::PregMatchEx ( {$subject}, {$re}, NOWIPE ) : ";
$result = Regex::PregMatchEx($re, $subject, $match, PREG_OFFSET_CAPTURE);
echo "\t" . str_replace("\n", "{$eol}{$tab}", print_r($match, true));
echo $eol;
// MetaPregMatchEx() example
$regex_list = ['1' => '/message start/', '2' => '/log: \\s* (?P<logmessage> .*)/imsx', '3' => '/message end/'];
$sequence = '/ \\1 \\2* \\3 /imsx';
$lines = ['message start', 'log: this is log message 1', 'log: this is log message 2', 'message end'];
echo "Regex::MetaPregMatchEx ( ) = ";
$status = Regex::MetaPregMatchEx($sequence, $regex_list, $lines);
echo $status ? 'true' : 'false';