1
|
using System.Text.RegularExpressions;
|
2
|
|
3
|
namespace LDClient.detection {
|
4
|
|
5
|
public static class DebuggerInfoParser {
|
6
|
|
7
|
private const int ExpectedNumberOfMatches = 2;
|
8
|
|
9
|
private static readonly Regex SerialNumberRegex = new("(?<=Serial Number: )(.*)");
|
10
|
|
11
|
public static (string headSerialNumber, string bodySerialNumber) Parse(string dataTxt) {
|
12
|
var matches = SerialNumberRegex.Matches(dataTxt);
|
13
|
|
14
|
if (matches.Count != ExpectedNumberOfMatches) {
|
15
|
throw new ArgumentException($"Expected {ExpectedNumberOfMatches} matches to be found in the text (actually found: {matches.Count})");
|
16
|
}
|
17
|
|
18
|
return (matches[1].ToString().Trim(), matches[0].ToString().Trim());
|
19
|
}
|
20
|
}
|
21
|
}
|