![](/img/trans.png)
[英]How to preg_grep on a particular number with different format in PHP?
[英]PHP preg_grep multi files
如何排除更多诸如branding.php的文件? 例如branding.php,about.php,contact.php。
$pages = preg_grep('/branding\.php/', glob("*.php"), PREG_GREP_INVERT);
谢谢。
在正则表达式中使用替代:
$pages = preg_grep('/\b(?:branding|about|contact)\.php/', glob("*.php"), PREG_GREP_INVERT);
哪里
\\b
:单词边界以避免匹配abranding
或abc123about
... (?:branding|about|contact)
:与branding
OR about
OR contact
相匹配的非捕获组(您可以添加更多文件)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.