Page 1 of 1

Insert '***End***' before...

Posted: Tue Dec 30, 2008 3:12 am
by agent86
Every time I find a line that starts with 'MSH|^~\&|' I want to insert a line before that line that contains '***End***'. For example:

MSH|^~\&|POWERP
PID|1||||SPROSS
PV1|1||||||1693
ORC|SC|FN080111
MSH|^~\&|POWERP
PID|1||||SPROSS
PV1|1||||||1693
ORC|SC|FN080111
MSH|^~\&|POWERP
PID|1||||SPROSS
PV1|1||||||1693
ORC|SC|FN080111


becomes

***End***
MSH|^~\&|POWERP
PID|1||||SPROSS
PV1|1||||||1693
ORC|SC|FN080111
***End***
MSH|^~\&|POWERP
PID|1||||SPROSS
PV1|1||||||1693
ORC|SC|FN080111
***End***
MSH|^~\&|POWERP
PID|1||||SPROSS
PV1|1||||||1693
ORC|SC|FN080111

Posted: Tue Dec 30, 2008 3:21 am
by Bob Hansen
1. Make sure you have a blank line at the top.

2. Search for: \nMSH
Replace with \n***End***\nMSH

=============================
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------

Posted: Tue Dec 30, 2008 11:13 am
by ben_josephs
You don't need the blank line at the top. Use
Find what: ^MSH
Replace with: ***End***\nMSH

[X] Regular expression

Replace All
But perhaps MSH doesn't occur at the top of the file anyway.

(Both Bob's suggestion and this one work with either the default or Posix regular expression syntax.)