Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i have this iso8583 message
0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890


now i want to find out in which byte array field is present.below output i need using c#.
i know bitmap shows which fields are present in message. but i am still not able to get output which i needed.
CSS
Field-3 : 201234
Field-4 : 000000010000
Field-7 : 0110722180
Field-11 : 123456
Field-44 : A5DFGR
Field-105 : ABCDEFGHIJ 1234567890

how can i do this ?
Posted
Updated 14-Nov-14 22:48pm
v2

check this codeproject article :BIM-ISO8583[^]
 
Share this answer
 
Comments
George Jonsson 15-Nov-14 11:53am    
Probably a better solution.
Using Regular Expressions[^] is one way to solve the problem.

Note that this code will only work the positions in the message are static.
C#
Regex rx = new Regex(@"^(?<field1>[0-9A-F]{14})(?<field2>[0-9A-F]{22})(?<field3>[0-9A-F]{6})(?<field4>[0-9A-F]{12})(?<field7>[0-9A-F]{10})(?<field11>[0-9A-F]{6})(?<field12>[0-9A-F]{2})(?<field44>[0-9A-Z]{6})(?<field45>[0-9A-F]{3})(?<field105>[0-9A-Z ]+)$", RegexOptions.IgnoreCase);

(I put in some dummy fields to match the pattern)
C#
string input = "0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890";
Match m = rx.Match(input);
if (m.Success)
{
    string field3 = m.Groups["field3"].Value;
    string field4 = m.Groups["field4"].Value;
    // etc.
}


[Update]
If the string is dynamic, but you know the position and length of the the parts you want, you can use String.SubString to do the extraction.
C#
string input = "0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890";
int pos3 = 36;
int length3 = 6;
string field3 = input.Substring(pos3, length3);

int pos4 = pos3 + length3;
int length4 = 12;
string field4 = input.Substring(pos4, length4);
// etc.
 
Share this answer
 
v3
Comments
deepak690 15-Nov-14 6:08am    
@George Jonsson thanks for the answer. can you tell me how can we achieve this if my string is dynamic
George Jonsson 15-Nov-14 6:15am    
Well, it depends what information you have about the string.
If you know position and length you can also use String.SubString.
deepak690 15-Nov-14 6:52am    
george if my length is also dynamic then how i achieve this? sometimes field length is 12 next time 15,16 etc then? i mean field length
George Jonsson 15-Nov-14 7:35am    
If the length is also dynamic you need to know the length beforehand unless you have a control pattern in the string that can be used to find the position and length for a wanted field on the fly.
deepak690 15-Nov-14 6:19am    
ok george.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900