![](/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.