Let's imagine i have some regex pattern:
(a)|(b)|(c)
How to identify what match has been triggered? Is there some kind of index of match?
I can check all groups for null or compare global Value field with group Value fields or separate pattern to many and check them through line of " if ", but its kinda crappy and gives additional complexity. Is regex don't have some finite state value?
Sure you can do this:
match.Groups[1].Success // true or false
match.Groups[2].Success // true or false
match.Groups[3].Success // true or false
You could also name your groups to make it easier to follow:
(?<foo>a)|(?<bar>b)|(?<baz>c)
match.Groups["foo"].Success // true or false
match.Groups["bar"].Success // true or false
match.Groups["baz"].Success // true or false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.