Extract comma separated portion of string with a RegEx in C#

后端 未结 4 1365
失恋的感觉
失恋的感觉 2021-01-22 17:22

Sample data: !!Part|123456,ABCDEF,ABC132!!

The comma delimited list can be any number of any combination of alphas and numbers

I want a regex to match the entri

4条回答
  •  -上瘾入骨i
    2021-01-22 18:05

    Unless I'm mistaken, that still only counts as one group. I'm guessing you'll need to do a string.Split(',') to do what you want? Indeed, it looks a lot simpler to not bother with regex at all here... Depending on the data, how about:

            if (tag.StartsWith("!!Part|") && tag.EndsWith("!!"))
            {
                tag = tag.Substring(7, tag.Length - 9);
                string[] data = tag.Split(',');
            }
    

提交回复
热议问题