c# - Regular expression group matching not working -
what missing here?
regex _validityregex = new regex(@"^(<minstay>.{2})\/(<maxstay>.{2})$"); match validitymatch = _validityregex.match("--/3m);
i want 2 groups 1 containing first 2 characters , 1 containing second 2 after /
please use next pattern (you have missed ?
):
@"^(?<minstay>.{2})/(?<maxstay>.{2})$"
you may acces groups this:
var minstay = validitymatch.groups["minstay"].value var maxstay = validitymatch.groups["maxstay"].value
Comments
Post a Comment