Dennis,
Thanks for the push.
I was looking at
http://www.regular-expressions.info/reference.html and had just read about character classes when I received your reply.
I continued looking and found a CL example that I was able to modify to get the desired result
PGM
DCL VAR(&X0D) TYPE(*CHAR) LEN(1) VALUE(X'0D')
DCL VAR(&X25) TYPE(*CHAR) LEN(1) VALUE(X'25')
DCL VAR(&SEDCMD) TYPE(*CHAR) LEN(100)
CHGVAR VAR(&SEDCMD) VALUE('sed +
"s%[\][.]br[\]%\'||&x0D||'\'||&X25||'%g"
/joe/temp/in.hl7 > /joe/temp/out.hl7')
QSH CMD(&SEDCMD)
ENDPGM
Is this what you had in mind?
Of course, I am curious as to why we have to do it this way!
Thanks,
Joe
Joe Wells
University of Alabama Health Services Foundation
500 22nd Street South, Suite 308
Birmingham, AL 35233
205-731-5610
CONFIDENTIALITY NOTICE
This e-mail is intended for the sole use of the individual(s) to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. You are hereby notified that any dissemination, duplication or distribution of this transmission by someone other than the intended addressee or its designated agent is strictly prohibited. If you receive this e-mail in error, please notify me immediately by replying to this e-mail.
Dennis Lovelady<iseries-HF96MFG82JhWk0Htik3J/w@xxxxxxxxxxxxxxxx> 3/19/2010 12:40 PM >>>
This is the command I am running:
qsh cmd('sed "s%[\.br\]%\r\n%g" /joe/temp/in.hl7 > /joe/temp/out.hl7')
in.hl7 contains this -
\.br\hello\.br\joe
after running the command, out.hl7 contains this -
rnrnrnrnrnhellornrnrnrnrnjoe
Yes. You are telling sed to replace any backslash, any period, any b, or
any r with the sequence of \r\n. It's doing that because you've defined a
class to be replaced, and the class contains all those characters. ->
[\.br\] <- This is not what you want. You want a command more like this:
sed s%[\][.]br[\]%\r\n% (or the more obvious but less readable
s%\\\.br\\%\r\n%)
But I'm not sure why the \r\n is not being converted to CRLF. Pretty sure
that will work on a unix system. Hmmm... a challenge, since I see that
doesn't work in either QSH or PASE. Hmmm... If I were on a unix terminal
or writing a unix script, I'd just include a CTRL+M between the quotes, but
that won't work here.
If someone doesn't provide you a better solution, I will post a CL program
(as an example) that can do this.
Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"More than half (55 percent) of women undergraduates are female."
-- About Women on Campus, newsletter published by the National
Association for Women in Education
As an Amazon Associate we earn from qualifying purchases.