我正在使用正则表达式搜索来匹配和替换某些文本。文本可以跨越多行(可能有或没有换行符)。 目前我有这样的:查找跨越文本的多行并使用PowerShell替换
$regex = "\<\?php eval.*?\>"
Get-ChildItem -exclude *.bak | Where-Object {$_.Attributes -ne "Directory"} |ForEach-Object {
$text = [string]::Join("`n", (Get-Content $_))
$text -replace $RegEx ,"REPLACED"}
我想你想'Where-Object {!$ _ PSIsContainer}',它绝对是一个更好的方式去IMO(与测试属性)。 – 2010-06-17 16:58:49
@凯斯,我的错。谢谢 :) – stej 2010-06-17 17:02:43