c# - Problems validating Regex.IsMatch -


i have problem regx.ismatch. need validate string in format, @"[o]-[0-9]{8}-[0-9]{5}-[0-9]-[0-9]-[0-9]", using code:

if (!regex.ismatch(vm.cadastralnumber, @"[o]-[0-9]{8}-[0-9]{5}-[0-9]-[0-9]-[0-9]"))        modelstate.addmodelerror("cadastralnumber", "prefix should o, or format not correct"); . 

but got problem, after format need user not allow write more number -[0-9]-[0-9]-[0-9]-[0-9]. never stops, need users write format gave first, ad not alow writting more -. help?

write @"^[o]-[0-9]{8}-[0-9]{5}-[0-9]-[0-9]-[0-9]$" make regex match beginning (^) , end ($) of string.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -