string strRegexclass = @"^([0-9]+)\-([a-zA-Z])$";
I want to make regular expression which accept input like this (1-class). Any integer value before dash(-) and then must have dash then anything after dash.
string strRegexclass = @"^([0-9]+)\-([a-zA-Z])$";
I want to make regular expression which accept input like this (1-class). Any integer value before dash(-) and then must have dash then anything after dash.
You can use the code like this:
string strRegexclass = @"^\d+-.*$";
Or you can use the next code
string strRegexclass = @"^\d+-\w*$";
if you want to allow only letters after the dash.
If you plan to only match a string that starts with 1 or more ASCII digits, then a hyphen, and then any 0+ chars use:
^[0-9]+-.*$
See the regex demo