Получить Match из Regex
У меня есть Regex regex = new Regex(@"(?<Property>[^:|;]+):(?<Value>[^:|;]+);");
Как мне получить Match где Property = "Таблица"?
Хотел вот-так но так нельзя:
Match match = regex.Match(str).where(b=>b.Groups["Property"] == "Таблица")
Ответы (1 шт):
Автор решения: Alexander Petrov
→ Ссылка
Одно первое совпадение:
Match match = regex.Matches(str)
.AsEnumerable()
.First(m => m.Groups["Property"].Value == "Таблица");
Коллекция совпадений:
var matches = regex.Matches(str)
.AsEnumerable()
.Where(m => m.Groups["Property"].Value == "Таблица");