using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms.VisualStyles; namespace HighWayIot.TouchSocket { /// /// 客户端字符串解析 /// public class ClientStringAnalysis { /// /// Getinfo信号解析 /// 格式为 /// From 001 /// qwertyuiopasdfghjklzxcvbnm[]\;',./!@#$%^&*()_+1234567890-=`~ /// /// 所有的From信号 public static string[] GetInfoAnalyzer(string mes) { if (string.IsNullOrWhiteSpace(mes)) { return Array.Empty(); } // 按行分割输入 string[] lines = mes.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); List result = new List(); foreach (string line in lines) { // 检查并提取符合格式的 "From XXX" if (line.StartsWith(" > From ")) { string number = line.Substring(8, 3); // 提取后三位数字 result.Add(number); } } return result.ToArray(); } } }