可以使用以下正则表达式来获取T1到T6的值:

string pattern = @"T1: ([\d.-]+)\r\nT2: ([\d.-]+)\r\nT3: ([\d.-]+)\r\nT4: ([\d.-]+)\r\nT5: ([\d.-]+)\r\nT6: ([\d.-]+)";

使用Match方法来匹配正则表达式:

Match match = Regex.Match(input, pattern);

然后可以通过match.Groups来获取每个T值的值:

string t1 = match.Groups[1].Value; string t2 = match.Groups[2].Value; string t3 = match.Groups[3].Value; string t4 = match.Groups[4].Value; string t5 = match.Groups[5].Value; string t6 = match.Groups[6].Value;

注意,这里的[\d.-]+表示匹配数字、点号和负号,+表示匹配一个或多个。如果需要匹配其他字符,可以在方括号中添加

C# 用正则表达式获取下文T1:~ T6:的值 TEMPrnT1 2777rnT2 -23057rnT3 -23057rnT4 -23057rnT5 -23057rnT6 -23057rnT7 -23057rnT8 -23057rn

原文地址: https://www.cveoy.top/t/topic/enfb 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录