You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms.VisualStyles;
|
|
|
|
namespace HighWayIot.TouchSocket
|
|
{
|
|
/// <summary>
|
|
/// 客户端字符串解析
|
|
/// </summary>
|
|
public class ClientStringAnalysis
|
|
{
|
|
/// <summary>
|
|
/// Getinfo信号解析
|
|
/// 格式为
|
|
/// From 001
|
|
/// qwertyuiopasdfghjklzxcvbnm[]\;',./!@#$%^&*()_+1234567890-=`~
|
|
/// </summary>
|
|
/// <returns>所有的From信号</returns>
|
|
public static string[] GetInfoAnalyzer(string mes)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(mes))
|
|
{
|
|
return Array.Empty<string>();
|
|
}
|
|
|
|
// 按行分割输入
|
|
string[] lines = mes.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
|
List<string> result = new List<string>();
|
|
|
|
foreach (string line in lines)
|
|
{
|
|
// 检查并提取符合格式的 "From XXX"
|
|
if (line.StartsWith(" > From "))
|
|
{
|
|
string number = line.Substring(8, 3); // 提取后三位数字
|
|
result.Add(number);
|
|
}
|
|
}
|
|
|
|
return result.ToArray();
|
|
}
|
|
}
|
|
}
|