我試圖過濾掉所有不以.html
結尾的文件。最重要的是,它們都以不同的日期開始,所以只有那些符合日期模式的日期。排除以.html結尾的所有結果
文件名的例子:
2015-06-23 1003 (Tuesday) - Inconsistencies found.html
2015-06-23 1003 (Tuesday) - Groups without place holder account.txt
2015-06-23 1003 (Tuesday) - Inactive users.csv
2015-06-23 0948 (Tuesday) - Inconsistencies found.html
2015-06-23 0948 (Tuesday) - Description not following the standard.csv
2015-06-23 0948 (Tuesday) - Groups without place holder account.txt
預期結果:
# when $d = 2015-06-23 1003
2015-06-23 1003 (Tuesday) - Groups without place holder account.txt
2015-06-23 1003 (Tuesday) - Inactive users.csv
當前正則表達式:
$RegExAttachments = "^{0:00}-{1:00}-{2:00}\s{3:00}{4:00}\s\({5}\).*\." -f $d.Year,$d.Month,$d.Day,$d.Hour,$d.Minute,$d.DayOfWeek
$Attachments = Get-ChildItem $LogFolder | where {$_.Name -match $RegExAttachments} | foreach {$_.FullName}
$Attachments
當前的正則表達式提供了正確的結果,但是,它還包含以HTML結尾的文件,我希望在結果中避免使用該文件。我也嘗試過"^{0:00}-{1:00}-{2:00}\s{3:00}{4:00}\s\({5}\).*\.[^html]"
,但是它也沒有調出txt files
。