【发布时间】:2022-01-25 09:46:58
【问题描述】:
$ignoreList = @("muzi","puzi")
$data = "
blabla aa 11
blabla bb 22
muzi aa 20
muzi bb aa
aaa aa 41
blabla aa 20
puzi aa 11
puzi bb 32
puzi cc 44"
我需要创建新数据,其中包含所有数据,除了那些也在忽略列表中的数据
#i can iterate the list and run a loop, get $str to be the item in the list and
#and then save each time
$data | where-object {$_ -notlike $str}
我认为有比每次迭代列表 abd savubg 更好的选择
【问题讨论】:
-
$ignoreList.ForEach{ $Data = $Data -Replace $_ }; $Data -
[1] 您将
$Datathru 作为一个多行字符串发送。那是你要的吗?还是你想处理每一行? ///// [2] 你想删除单词...还是包含这些单词的行? ///// [3] 尝试使用-replace和正则表达式或模式。类似ThingOne|2ndThing|YetAnotherThing.
标签: powershell