If you are actually handling real HL7 messages, you should study the HL7 specification a little closer. I have found the links below to be quite useful:
http://www.interfaceware.com/hl7.html[
^]
http://www.interfaceware.com/hl7-standard/[
^]
Make sure you check out
this[
^] small sample, which says (among other things)
"A carriage return character (\r, which is 0D in hexadecimal) separates one segment from another". This means that you should not (or don't have to) split up your string based on the segment names, but on the CR separator. This makes it a bit simpler to deal with.
Soren Madsen