c# - Regular Expression: Search key validation -
please regular expression. working on validating string. value should not contain % , if there % length should more 3 characters including %. % can anywhere in string (dot included).
i come this. validation should happen when % in string. if there no % no validation necessary.
@"^[a-za-z0-9'.]*%"; //{3,}$";
thanks, naveen
examples:
"%"- fail"%12"- fail"%123"- pass"%1234"- pass"12%3"- pass"abc%"- pass"abc"- pass"a"- pass"abc"- pass
i don't think needs regex solve, string methods ok:
var valid = !input.contains("%") || input.length > 3; if want use regex, here are:
^([^%]+|.{4,})$
Comments
Post a Comment