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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -