使用多个分隔符拆分String [英] Split a String with multiple deliminator

查看:101
本文介绍了使用多个分隔符拆分String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串,我想根据不同的单词拆分。



I have a String that I want to Split on basis of diffrent word.

string s = "MSH|^~\&|EPIC|EPICADT|SMS|SMSADT|199912271408|CHARRIS|ADT^A04|1817457|D|2.5|PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203|M||B|254 MYSTREET AVE^^MYTOWN^OH^44123^USA||(216)123-4567|||M|NON|400003403~1129086|NK1||ROE^MARIE^^^^|SPO||(216)123-567||EC|||||||||||||||||||||||||||
PV1||O|168 ~219~C~PMA^^^^^^^^^||||277^ALLEN MYLASTNAME^BONNIE^^^^||||||||||||2688684|||||||||||||||||||||||||199912271408||||||002376853 "



在这里,我想把这个字符串分成多行字符串,无论我们在哪里找到以下单词

string



(MSH,PID,NK1,PV1)



pleasse给我一个解决方案,如果有人拥有它。


Here, I want to split this string into multiple line string wherever we found following words in
string

(MSH,PID, NK1, PV1 )

pleasse give me a solution if anyone have it.

推荐答案

如果您实际处理真正的HL7消息,您应该更仔细地研究HL7规范。我发现下面的链接非常有用:

http://www.interfaceware.com/hl7 .html [ ^ ]

http://www.interfaceware.com/hl7-standard/ [ ^ ]



确保检查这个 [ ^ ]小样本,其中说明(其中包括) 回车符(\ r,十六进制为0D)将一个段与另一个。这意味着您不应该(或不必)根据段名称拆分字符串,而是在CR分隔符上拆分。这使得它更容易处理。



Soren Madsen
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


看看http://msdn.microsoft.com/en -us / library / tabh47cf.aspx?cs-save-lang = 1& cs-lang = csharp#code-snippet-4 [ ^ ]

Have a look into http://msdn.microsoft.com/en-us/library/tabh47cf.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-4[^]
string[] separators = {"MSH", "PID"};
string value = "MSH|^~ ... ....";
string[] words = value.Split(separators, StringSplitOptions.RemoveEmptyEntries);





PS:我希望你知道PHI



PS: I hope you are aware of PHI


这篇关于使用多个分隔符拆分String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆