Check Format of a string
c#, pattern-matching, string
Solution
private static readonly Regex boxNumberRegex = new Regex(@"^\d-\d{5}$");
public static bool VerifyBoxNumber (string boxNumber)
{
return boxNumberRegex.IsMatch(boxNumber);
}
Problem
What is the smallest amount of C# possible to Check that a String fits this format `#-#####` (1 number, a dash then 5 more numbers). It seems to me that a regular expression could do this quick (again, I wish I knew regular expressions). So, here is an example: ``` public bool VerifyBoxNumber (string boxNumber) { // psudo code if (boxNumber.FormatMatch("#-#####") return true; return false; } ``` If you know real code that will make the above comparison work, please add an answer.