本文整理汇总了PHP中Regex::DevelopExpression方法的典型用法代码示例。如果您正苦于以下问题:PHP Regex::DevelopExpression方法的具体用法?PHP Regex::DevelopExpression怎么用?PHP Regex::DevelopExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Regex
的用法示例。
在下文中一共展示了Regex::DevelopExpression方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
$re = ['/foo bar/', '#foo bar#imsx', '/foo bar'];
foreach ($re as $item) {
echo "Regex::IsRegex ( {$item} ) = " . (Regex::IsRegex($item) ? 'true' : 'false') . $eol;
}
echo $eol;
// Matches() example
$matches = [['file.txt', '*.txt'], ['file.txt', 'file.*'], ['dir/file.txt', '*.txt'], ['dir/file.txt', 'dir/*.txt'], ['dir/file.txt', '*/*.txt'], ['dir/file.txt', '*\\file.txt']];
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;