假設我有一個文件夾中有5個文件。和文件名是一樣sdfsf([email protected])以下如何從多個文件名得到括號之間的字符串?
- - 2015年12月5日0508.eml
- sdfsdf SD毛刺」([email protected]) - 2015年12月30日0602.eml
- 不是那麼容易([email protected]) - 2015年12月31日1719.eml
- HABI揸([email protected]) - 2016年1月6日0513.eml
- 你應該([email protected]) - 2015-12-27 1227.eml
現在我想從文件名中得到「()」括號之間的字符串,並希望將它們保存在文本文件中。
所以輸出將類似下面
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
我試過這個代碼
<?php
foreach (glob("./ABC/*.txt") as $filename) {
echo "$filename size " . filesize($filename) . "\n";
}
?>
作爲正則表達式,'\((。*)\)'? https://regex101.com/r/gK1yK1/1 – Andrew