0

I am looking to pull data between curly braces using powershell.

File content:

MODULE TAG="TT203-1" PLANT_AREA="SLURRY" CATEGORY=""
VALUE_CHANGED=T
HAS_DEFAULT_VALUE=F
ALARM_HELP
  {
  ALARM_CONSEQUENCE_OF_INACTION=2
  ALARM_TIME_TO_RESPOND=10
  HELP_TEXT_1="1.  Stop unloading of delivery truck.
  2.  If no delivery in progress, shut all manual valves leading to and from the tank."
  HELP_TEXT_2="1. Overfilled by new delivery
  2.  Backflow from another process
  3. Level Transmitter failure"
  HELP_TEXT_3="Overfill of the tank will result in a reportable environmental spill and safety hazard"
  }

I want to pull the "MODULE TAG" line and what is between the curly brackets following ALARM_HELP. I have been doing a fair amount of powershell, but this is beyond my level.

ldusing
  • 1
  • 1
  • Is there something you have tried for this we can help build on? Is that the _entire_ file content as in nothing precedes or follows what you show here? – Matt Aug 17 '17 at 16:32
  • Ok, I got this working by using $regex = [regex] '(?<=ALARM_HELP).*?(?=})' $subject = gc ./$plant.fhx $regex.Matches($subject) | foreach{$_.Value} However, I am now trying to get it working by using select-string, so I can pull other lines as well. Select-String -path ./$Plant.fhx -pattern 'MODULE TAG=',$regex as a concept. – ldusing Aug 18 '17 at 18:18

0 Answers0