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

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
agent86
Posts: 18
Joined: Wed Apr 26, 2006 2:59 am
Location: SF Bay Area

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

Post 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
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post 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
-----------------------------------------
Hope this was helpful.............good luck,
Bob
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.)
Post Reply