namespace NexusReader.Application.Utilities; /// /// Shared utility for parsing numeric segment identifiers from IDs like "seg-42". /// Centralizes the parsing contract to avoid duplication across handlers and UI components. /// public static class SegmentIdParser { /// /// Extracts the numeric portion from a segment identifier string (e.g., "seg-42" → 42). /// Returns 0 if the string is null, empty, or contains no digits. /// public static int Parse(string? id) { if (string.IsNullOrEmpty(id)) return 0; var digits = new string(id.Where(char.IsDigit).ToArray()); return int.TryParse(digits, out var val) ? val : 0; } }