in regex pattern this:
@"something\(\d+, ""(.+)""(, .{1,5}, \d+, (?<somename>\d+)?\),"
so know if <somename>
exists. if normal capture group, check if capture groups greater number of groups without that/those capture group(s), don't have option here.
could me find way round this? don't need efficient, it's one-time program that's used sorting, don't mind if takes bit run. it's not going public code.
according documentation:
if groupname not name of capturing group in collection, or if groupname name of capturing group has not been matched in input string, method returns group object group.success property false , group.value property string.empty.
var regex = new regex(@"something\(\d+, ""(.+)""(, .{1,5}, \d+, (?<somename>\d+)?\),"); var match = regex.match(input); var group = match.groups["somename"]; bool exists = group.success;
Comments
Post a Comment