以下是我的代码
Dim ReadTagdata As String = "Info,Reply:Axis 0, Channel G, Timestamp 2eff, SpecificID f00ba36d, CRC d01ed74e, ReadAddress 000a, Data: 7a7a 3433 3132 3334 3536 3738 3637 2c31 352c 302e 3036 2c2e 3930 2d31 2e32 322c 526f 756e 642c 462c 5653 322c 7665 7279 2067 6f6f 642c 676f 6f64 2c76 6572 7920 676f 6f64 2c6d 6564 6975 6d2c 4852 442c 3137 3530 3234 3837 3333 2c32 352d 4175 672d 3130 2c33 2e39 342c 332e 3932 2c32 2e38 322c 332e 3839 2c35 362c 3131 2e35 2c34 332c 6d65 6469 756d 2c70 6f69 6e74 6564 2c2c 2c2c 2c2c 4e2c 2c2c 2c2c 2c2c 2c2c"
Dim Specificcol As MatchCollection = Regex.Matches(ReadTagdata, "SpecificID ([a-f0-9]{8})")
For Each m As Match In Specificcol
Dim g As Group = m.Groups(1)
MsgBox(g.Value.ToString)
Next
Dim DataCol As MatchCollection = Regex.Matches(ReadTagdata, "Data: ([A-Za-z0-9\-]+) ", RegexOptions.IgnoreCase)
For Each mdata As Match In DataCol
Dim gdata As Group = mdata.Groups(1)
Dim data As String = gdata.Value.ToString
MsgBox(data)
Next
在上面我试图检索的代码中,需要使用正则表达式从 ReadTagData 字符串中获取数据,但使用以下代码,我只能在Data: string ie 7a7a 之后检索 1 个值, 而不是那个,我想要"数据:”字符串
Dim DataCol As MatchCollection = Regex.Matches(ReadTagdata, "Data: ([A-Za-z0-9-]+) ", RegexOptions.IgnoreCase)
提前致谢