Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the RegEx mehod to insert string values ino array elemens.

Status
Not open for further replies.

Sanjeet1

Programmer
Sep 4, 2003
26
US
Using the RegEx mehod to insert string values ino array elemens.

I retreive a byte array through a tcp client. I then inser the byte array ino a string.


string cs = encoding.GetString(b);

The String variable contains info similar to this:

MSH|^~\\&|AXO|Axolotl Corp.|Elysium Connection|Children's Surgical Foundation|20050712144222||MDM^T02|ATMS.6E7UG2|P|2.3.1||||||^^^^^^\\nEVN|||||||||||||\\nPID|||972114^^^^MR^||WILSON^REESE^ ||20030724|F||||||||||||||||||||||\\nPV1||U||||| ^KING^ERIK^ ^^^ ^ |||||||||||||||||||||||||||||||||||||||||||||\\nOBX||RP|||20050712141124-0-ATMS-6E7UG2.pdf\\n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"


What I need to do is take this information and store it in an array. The array should contain information depending on the following header information:

MSH Message Header
EVN Event Type
PID Patient Identification
PV1 Patient Visit Information
I saw this link:


Here is my code:

ASCIIEncoding encoding = new ASCIIEncoding( );
string cs = encoding.GetString(b);

String[] CMHarray = Regex.Split(cs, "\n");
string strMHS;
CMHarray(0) = strMHS;

But when I tried to access each element I got an error message sayinng:

denotes a 'variable' where a 'method' was expected

I also tried CMHAray[0] = strMHS
 
I think that only problem is that instead
CMHarray(0) = strMHS;

you should use
CMHarray[0] = strMHS;

 
I tried that I got the same error message.

Thanks.
 
nastoski was correct for the syntax he have you. However, I am a little confused on what you are trying to do. From what I can gather in your code, you are breaking up your cs string and putting each chunk into your CMHarray string[]. Then you declare strMHS, set CMHarray[0] equal to it, but don't set it to anything. I'm not sure if it has anything to do with your problem, though

--Brad

"Life is too important to be taken seriously" --Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top