我正在读取一个文本文件,如果一行以字符串开头并以数字结尾,我需要在其中过滤并执行一些格式化。如果我知道/修复了值,我可以使用 StartWith 或 EndsWith 来过滤这一行。我尝试如下使用它,但我想这是错误的,因为它不起作用。
if(($record.StartsWith.GetType() -eq [string]) -and ($record.EndsWith.GetType() -eq [int]))
示例:我的行已读
TransDate,Merchant,Amount
Doe,Jane, *6098
3/4/2020,Walmart,6.45
3/4/2020,Starbucks,14.45
Doe,John, *6096
3/4/2020,Amazon,34.45
我需要确定第 2 行和第 5 行有我的卡号。如何在 powershell 中识别这些?请告诉我。谢谢