Page 1 of 1

Add phrase to blank line above certain lines...

Posted: Fri May 15, 2009 1:29 am
by agent86
I want to do the following... insert '***END***' on the blank line above any line that starts with 'MSH|^~\'

before:

MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||KOAD01^Koala^Diana^K
ORC|NW||P09-035258||||||2009050
OBR|1||P09-035258|GYN^PAP Smear

MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||DANA01^Daniel^Anna^G
ORC|NW||P09-035259||||||2009050
OBR|1||P09-035259|GYN^PAP Smear

MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||KOAD01^Koala^Diana^K
ORC|NW||P09-035258||||||2009050
OBR|1||P09-035258|GYN^PAP Smear

MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||DANA01^Daniel^Anna^G
ORC|NW||P09-035259||||||2009050
OBR|1||P09-035259|GYN^PAP Smear

after:

***END***
MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||KOAD01^Koala^Diana^K
ORC|NW||P09-035258||||||2009050
OBR|1||P09-035258|GYN^PAP Smear
***END***
MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||DANA01^Daniel^Anna^G
ORC|NW||P09-035259||||||2009050
OBR|1||P09-035259|GYN^PAP Smear
***END***
MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||KOAD01^Koala^Diana^K
ORC|NW||P09-035258||||||2009050
OBR|1||P09-035258|GYN^PAP Smear
***END***
MSH|^~\&|CELLNETIX|PATHOLOGY|||
PV1|1||||||DANA01^Daniel^Anna^G
ORC|NW||P09-035259||||||2009050
OBR|1||P09-035259|GYN^PAP Smear

Posted: Fri May 15, 2009 3:14 am
by Bob Hansen
Thanks for the great "before" and "after" examples, makes it much easier to understand your problem.

Here is an untested solution to try:

Search for: \n\n(MSH\|\^~\\)
Replace with: \n***END***\n\1

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

Thank you..

Posted: Fri May 15, 2009 6:05 pm
by agent86
I love this forum!