public void HasValTest() { string pattern = @"@@@(\d{1}),"; var s = "HJ26440601099302019-07-18 13:17:19@@@2019-07-18 13:17:19.193tek1d####"; var b = RegexText.HasVal(s, pattern); Assert.False(b); s = "HJ26440601099302019-07-18 14:49:155fb265d5-0a0e-4359-8eb1-ecc187c49502@@@0,未进行连接注册tek74####"; b = RegexText.HasVal(s, pattern); var t = RegexText.MatchVal(s, pattern); Assert.True(b); s = "HJ26440601099302019-07-18 13:21:42d06b8091-791a-4c05-a87a-4eb5978c7c57@@@1,2019-07-18 13:21:42tek13####"; b = RegexText.HasVal(s, pattern); t = RegexText.MatchVal(s, pattern); s = "HJ26440601099302019-07-18 13:17:19@@@2019-07-18 13:17:19.193tek1d####"; pattern = "@@@(.*)tek"; t = RegexText.MatchVal(s, pattern, 1); Assert.True(b); }
public void TestMatch01() { string s = "2020/05/09 16:21:19 _[接收]_<?xml version=\"1.0\" encoding=\"GBK\"?></Result><Dev><FQYNAME></FQYNAME><FQYMODEL></FQYMODEL><YDJNAME>不透光烟度计</YDJNAME><YDJMODEL>MQY-202</YDJMODEL><RPMNAME>鸣泉转速计</RPMNAME><RPMMODEL>MQZ-4</RPMMODEL><NOxNAME>排放气体测试仪</NOxNAME><NOxMODEL>MQW-5102</NOxMODEL><CDMNAME>测功机</CDMNAME><CDMMODEL>CDM-300C</CDMMODEL><START_TIME>2020-05-09 16:21:19</START_TIME></Dev></Request>"; RegexText.MatchVal(s, @"_\[接收\]_(.*)", 2); }