[英]I need to validate if first character of a string is a letter and next characters are either letters or numbers or special characters _,-,. and space
Please note:All characters are in English only.请注意:所有字符均为英文。
I tried Regex.IsMatch(item, @"^[a-zA-Z][a-zA-Z0-9_.-]+$")
but doesn't work expectedly我试过
Regex.IsMatch(item, @"^[a-zA-Z][a-zA-Z0-9_.-]+$")
但没有按预期工作
Regex.IsMatch(item, @"^[a-zA-Z][a-zA-Z0-9_. -]*$") Regex.IsMatch(item, @"^[a-zA-Z][a-zA-Z0-9_.-]*$")
There is a space between '.' '.' 之间有一个空格and '-'
和 '-'
Thanks all for your suggestions.谢谢大家的建议。 My sample inputs are: Vikash,Vikash kumar,Vikash.
我的示例输入是:Vikash、Vikash kumar、Vikash。 kumar,Vikash9_.
库马尔,维卡什9_。 kumar <-these should be supported
kumar <-这些应该得到支持
and和
9Vikash,Vikash*hj,Vikash&9,%ghj <-these shouldn't be supported 9Vikash,Vikash*hj,Vikash&9,%ghj <-这些不应该被支持
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.