1) How can I merge lines that have an &, then find if 2 words exists to then replace 3 words?
Original string:
SUBFILE EMF147.PUB &
KEEP &
SIZE 50000 &
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
find SUBFILE AND SIZE
Continuation character is &.
then take out SIZE and Next word (Value of 50000 for this case).
note: the word SUBFILE can be SUB, or SUBF or SUBFI ...
also the words can be anywhere in the sentence except SUBFILE.
SUBFILE EMF147.PUB &
SIZE 50000 &
KEEP &
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
or
SUBFILE EMF147.PUB &
KEEP &
INCL SUBWHSE, DATE-ISSUE &
SIZE 50000 &
INDEX SUBWHSE
...
final result:
SUBFILE EMF147.PUB &
KEEP &
&
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
2) How can I find the word SUBFILE in the same scenario as above, but this time add the word KEEP if it isn't there in the sentence?
Original string:
SUBFILE EMF147.PUB &
KEEP &
SIZE 50000 &
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
result: do nothing.
Original:
SUBFILE EMF147.PUB &
SIZE 50000 &
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
result:
SUBFILE EMF147.PUB KEEP &
SIZE 50000 &
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
Thanks for the last answer, it worked well.
And hope you can do this, it would same me a lot of time.
Regards,
Charles
Merging lines with continuation character and doing replacem
Re: Merging lines with continuation character and doing repl
pelletic wrote:1) How can I merge lines that have an &, then find if 2 words exists to then replace 3 words?
For this case try the following
Search for:
SUB(.*)SIZE.*&(.*)\Z
Replace with:
SUB$1&$2
I tried it looks like it works.
Sure if needed these r.e. maybe customized to be more precise.
I tried it and it didn't work!
I cut and pasted the statement:
SUBFILE EMF147.PUB &
KEEP &
SIZE 50000 &
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
in the Regular expression builder,
then used your regular expression and replace by text, and nothing happened...
Maybe you have a different version than I have (version 2.0)
Or maybe it can't be done with your software!
Thanks anyway,
At least you tried.
I cut and pasted the statement:
SUBFILE EMF147.PUB &
KEEP &
SIZE 50000 &
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
in the Regular expression builder,
then used your regular expression and replace by text, and nothing happened...
Maybe you have a different version than I have (version 2.0)
Or maybe it can't be done with your software!
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
Thanks anyway,
At least you tried.
Charles
Verify that there are not trailing spaced before and after search and replace pairs. I tried first time and it did not work too.
But after that I found out there was a trailing space after \Z
So finally I got resulting code:
SUBFILE EMF147.PUB &
KEEP &
&
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
Does it work now?
But after that I found out there was a trailing space after \Z
So finally I got resulting code:
SUBFILE EMF147.PUB &
KEEP &
&
INCL SUBWHSE, DATE-ISSUE &
INDEX SUBWHSE
Does it work now?