Regex
-
Regex 정규식 활용 그룹명.NET/Common 2022. 9. 7. 13:11
static void Main(string[] args) { Regex regex = new Regex(@"^(?.+?)_(?.+)\..+$"); var match = regex.Match("TEST_PID12345678.csv"); Dictionary keyValues = new Dictionary(); if(match.Success) { foreach (string groupName in regex.GetGroupNames()) { if (char.IsDigit(groupName.ToCharArray()[0])) continue; //숫자로 그룹명 자동생성 keyValues.Add(groupName, match.Groups[groupName].Value); } Console.WriteLine(keyV..