
基本的には、文字列を検索し、完全一致または部分一致を CSV 形式で返します。
$Shoes
次のようなオブジェクトがあるとします。
"Brand","Style","Color","Price"
"Reebok","Basketball","Red/Black","$50"
"Vans","Slip-On","White/Black","$60"
"Vans","Old Skool","Red/White","$60"
"Nike","Sneakers","Red","$50"
"Adidas","Sneakers","Blue","$55"
読みやすくするために、表としてフォーマットすると次のようになります。
Brand Style Color Price
----- ----- ----- -----
Reebok Basketball Red/Black $50
Vans Slip-On White/Black $60
Vans Old Skool Red/White $60
Nike Sneakers Red $50
Adidas Sneakers Blue $55
入力すると$Shoes -like '*Red*'
次の結果が返されます:
@{Brand=Reebok; Style=Basketball; Color=Red/Black; Price=$50}
@{Brand=Vans; Style=Old Skool; Color=Red/White; Price=$60}
@{Brand=Nike; Style=Sneakers; Color=Red; Price=$50}
しかし、私が求めている出力は次のとおりです。
Brand Style Color Price
----- ----- ----- -----
Reebok Basketball Red/Black $50
Vans Old Skool Red/White $60
Nike Sneakers Red $50
ここで何が間違っているのでしょうか?
答え1
試したときに -match のフォーマットを間違っていたようですが、簡単な解決策であることがわかりました...
それは単純に$Shoes -match 'Red'