public static ConfTopicMsgRangeDTO GetTopicMsgRange(this Data.EF.Conference conf, string topicMsgRange, bool required = false) { // Regex: ^(.+?)(\.(\d+)(\-(\d+))?)?$ // Groups: 1 (topic), 3 (lo), 5 (hi) var regex = new Regex(@"^(.+?)(\.(\d+)\-?(\-(\d+))?)?$"); var match = regex.Match(topicMsgRange); if (!match.Success) { return(null); } var result = new ConfTopicMsgRangeDTO(); if (match.Groups.Count >= 1) { result.topic = conf.GetTopicFromStr(match.Groups[1].Value, required); } if (match.Groups.Count >= 3 && int.TryParse(match.Groups[3].Value, out int i)) { result.msgLow = i; } if (match.Groups.Count >= 5 && int.TryParse(match.Groups[5].Value, out i)) { result.msgHigh = i; } if (!topicMsgRange.EndsWith("-") && result.msgHigh == 0) { result.msgHigh = result.msgLow; } return(result); }