Projekt

Obecné

Profil

Stáhnout (762 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1 bab6f59d silhavyj
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[0].ToString(), matches[1].ToString());
19
        }
20
    }
21
}