The input text from allacts.txt is:
institutionId: blah blah,name: 1st thing,laestabNo: blah blah institutionId: blah blah,name: 2nd thing,laestabNo: blah blah, [lots more things] institutionId: blah blah,name: last thing,laestabNo: blah blah
The desired output is:
1st thing,laestabNo: blah blah 2nd thing,laestabNo: blah blah, [lots more things] last thing,laestabNo: blah blah
The command I am using within a powershell script:
Powershell -NoProfile "(Get-Content -Raw .\allacts.txt) -replace 'institutionid.*,name', '' | Out-File -FilePath allacts.txt -Force -Encoding ASCII"
What I actually get is:
last thing,laestabNo:blah blah
And nothing else. What am I doing wrong?
.means one character. the*means zero or more of the previous character. so you are telling it to replace EVERYTHING from the 1stinstitutionidto the last,name. [grin] take a look at "greedy & lazy matches" for how to limit that.