我遇到了regx.Ismatch
問題。我需要驗證一個字符串以這種格式,@"[O]-[0-9]{8}-[0-9]{5}-[0-9]-[0-9]-[0-9]"
,我使用此代碼:驗證Regex.IsMatch的問題
if (!Regex.IsMatch(vm.CadastralNumber, @"[O]-[0-9]{8}-[0-9]{5}-[0-9]-[0-9]-[0-9]"))
ModelState.AddModelError("CadastralNumber", "Prefix should be O, or the format is not correct"); .
但是我有一個問題,這種格式後,我需要的用戶不要讓寫更多的數字,如-[0-9]-[0-9]-[0-9]-[0-9]
。它永遠不會停止,我需要用戶首先寫出我給出的格式,並且不要寫更多 - 。任何幫助?
LINQ在哪裏? – xanatos 2015-04-01 09:33:22