Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I want to remove section and element of text file.
My text file is

Configuration
;
;   Authors: James
;   Created: 10/11/2018
;
;   Accepted

Name
    James
Class
    A2
Birthday
    1 September 1982
Family Member
    4
First Year Salary Number
    100 USD
Second Year Salary Number
    150 USD
Company Name
    Unlimited Company
Total Salary Number
    1300 USD
ExpectedSalaryNumber
    FY:350 USD
    SY:450 USD
    TS:2000 USD


I want to remove the whole content if the head contain of "Salary Number" and "SalaryNumber", also remove the title "Configuration.... " and output the file after remove it. My expectation output file is like this
Name
    James
Class
    A2
Birthday
    1 September 1982
Family Member
    4
Company Name
    Unlimited Company


What I have tried:

switch -regex -file .\BIOS.TXT
{
    'Salary\s*Number'
    {
     
    }
    default
    {
       $_
    }
}


I tried this, but it only remove the section name not include the item.
Posted
Updated 12-Nov-19 2:38am

Maybe also a case which would filter all lines ending with USD?
ps
switch -regex -file .\BIOS.TXT
{
   // ...
   '.*USD'
   {

   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900