JREPL.BAT - regex to remove lines in file

326 Views Asked by At

I have a source data file which I have been using JREPL.BAT to perform some very simple search and replace operations quite successfully. I now need to expand on that to do 2 jobs. 1. remove all lines that start with the string "appX_formContent". This line contain a lot of html output also, it all needs to be deleted on that line. 2. remove all lines that start with "Hex Payload:" and the subsequent line that comes with it.

This is an example of the input data file which shows 2 records. The delimiter between each record is the row that contains "-----------------".

-----------------
Message Headers
  JMSCorrelationID: 60bb7750-e9e2-11e9-98bb-42010a961307
  JMSPriority: 4
  JMSRedelivered: false
Message Properties
  app_trackingId: 190990a2-d8d8-43eb-814a-36ceba7a9111
  appX_formInstanceIdentifier: FRM389083
  appX_formContent: {"data":{"C7d14a6eb-70e7-402d-9d6e-4efd01ba561c":"N","Y","test.</p>\n<p>test form data&nbsp;to be informed&nbsp;</p>\n<p>...............</p>\n<p><strong>Update</strong></p>\n<p><strong>years</strong>"<p>supervision</p>","<p>:true,"c9377ae2-901d-4461-929c-c76e26dc6183":false}}}
  app_sourceSystemId: source
  app_eventCode: FORM_OUTPUT
  app_instigatingUserId: 66
  JMSXGroupSeq: 0
Hex Payload:
25 50 44 46 2D 31 2E 35 0D 0A 34 20 30 20 6F 62 6A 0D 0A 3C 3C 2F 54
-----------------
Message Headers
  JMSCorrelationID: 641a80d0-e9e2-11e9-98bb-42010a961307
  JMSPriority: 4
  JMSTimestamp: 2019 10 08 16:43:40
  JMSRedelivered: false
Message Properties
  app_trackingId: a3c2fe93-ef71-4611-9605-9858ff67a6e8
  appX_formInstanceIdentifier: FRM388843
  appX_formContent: {"data":{"C7d14a6eb-70e7-402d-9d6e-4efd01ba561c":"N","Y","test.</p>\n<p>test form data&nbsp;to be informed&nbsp;</p>\n<p>...............</p>\n<p><strong>Update</strong></p>\n<p><strong>years</strong>"<p>supervision</p>","<p>:true,"c9377ae2-901d-4461-929c-c76e26dc6183":false}}}
  app_sourceSystemId: source
  app_eventCode: FORM_OUTPUT
  app_instigatingUserId: 433
  JMSXGroupSeq: 0
Hex Payload:
25 50 44 46 2D 31 2E 35 0D 0A 34 20 30 20 6F 62 6A 0D 0A 3C 3C 2F
-----------------

This is the batch file that I use to call jrepl - very simple.

call jrepl ".*(?:appX_formContent: .*)" "" /m /f "inpu.txt" /o "output.txt"

I've only tried to remove the appX_formContent line with the regex but it isn't producing any output. I'm not good with regex so help appreciated. Not sure how to handle the second task of deleting the Hex Payload: line.

0

There are 0 best solutions below