日期:2014-05-17  浏览次数:20924 次

正则表达式,晕了
A55A0024850100000CE2801105200043049C830079000000000000000000000000DB0D0AA55A0024850100000CE2003412013BF00008E3481E1A0D013300045FFBFFFFDC50160D0A

按照开头是A55A002485 结尾是0D0A分成两个数组,用正则表达式怎么写???

------解决方案--------------------
正则表达式:(?is)A55A002485.*?0D0A
------解决方案--------------------
 string input = @"A55A0024850100000CE2801105200043049C830079000000000000000000000000DB0D0AA55A0024850100000CE2801105200043018B7A002E000000000000000000000000670D0AA55A0024850100000CE2801105200043018B7A002E000000000000000000000000670D0A";
            string pattern = @"(?i)A55A002485[\s\S]*?0D0A";

            List<string> result = Regex.Matches(input, pattern).OfType<Match>().Select(a=>a.Value).Distinct().ToList();
            /*

             [0] "A55A0024850100000CE2801105200043049C830079000000000000000000000000DB0D0A" string
[1] "A55A0024850100000CE2801105200043018B7A002E000000000000000000000000670D0A" string


             */