Powershell 提取字符串以

Vas*_*gas 0 powershell

我有一个包含以下内容的txt文件:

testdemo | 5 | 4563456| OMNI | retailomni
testRetail | 142 | 3453456345| testRetai111l | test
testtesttest | 44 | 4564356| apl | APL
Run Code Online (Sandbox Code Playgroud)

我需要选择从“testdemo”开始的整个字符串。这怎么能在PS中完成?

$operator = "testdemo"
$operatorcontent = Get-Content operators.txt | "Need to get whole string, starts from $operator"    
Run Code Online (Sandbox Code Playgroud)

小智 7

    Get-Content operators.txt | Select-String -Pattern "testdemo"
Run Code Online (Sandbox Code Playgroud)

将选择该行是否包含该行中任何位置的testdemo

如果要选择以testdemo开头的

    Get-Content operators.txt | Select-String -Pattern "^testdemo"
Run Code Online (Sandbox Code Playgroud)