回答編集履歴

1

?(Where-Object)と-notmatchを使った例を追記

2017/10/27 00:23

投稿

stknohg
stknohg

スコア796

test CHANGED
@@ -82,6 +82,24 @@
82
82
 
83
83
 
84
84
 
85
+ 【ちょっと追記】
86
+
87
+
88
+
89
+ この場合は`-replace`でなく`?(Where-Object)`と`-notmatch`を使ったほうがよりシンプルになりますね。
90
+
91
+
92
+
93
+ ```powershell
94
+
95
+ # 実行例
96
+
97
+ $txt | ? { $_ -notmatch "^[a.*$" }
98
+
99
+ ```
100
+
101
+
102
+
85
103
  ### 例2の場合
86
104
 
87
105
 
@@ -92,6 +110,8 @@
92
110
 
93
111
  ```powershell
94
112
 
113
+ # 実行例
114
+
95
115
  $txt -replace "^[a.*\n",$null
96
116
 
97
117
  ```