在c#中获取iso字段的字节数 [英] get iso fields byte numbers in c#
本文介绍了在c#中获取iso字段的字节数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个iso8583消息
i have this iso8583 message
0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890
now我想找出哪个字节数组字段存在。我需要使用c#。
i知道位图显示消息中存在哪些字段。但我仍然无法获得我需要的输出。
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.
Field-3 : 201234
Field-4 : 000000010000
Field-7 : 0110722180
Field-11 : 123456
Field-44 : A5DFGR
Field-105 : ABCDEFGHIJ 1234567890
我该怎么做?
how can i do this ?
推荐答案
检查这个代码项目文章: BIM-ISO8583 [ ^ ]
check this codeproject article :BIM-ISO8583[^]
使用正则表达式 [ ^ ]是解决问题的一种方法。
请注意,此代码仅适用于消息中的位置是静态的。
Using Regular Expressions[^] is one way to solve the problem.
Note that this code will only work the positions in the message are static.
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);
", RegexOptions.IgnoreCase);
(我输入一些虚拟字段来匹配模式)
(I put in some dummy fields to match the pattern)
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.
}
[更新]
如果字符串是动态的,但您知道所需部件的位置和长度,则可以使用 String.SubString
进行提取。
[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.
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.
>
这篇关于在c#中获取iso字段的字节数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文