简体   繁体   English

我需要验证字符串的第一个字符是否为字母,下一个字符是否为字母或数字或特殊字符 _、-、。 和空间

[英]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.

相关问题 正则表达式与数字和特殊字符,但没有字母 - Regex with numbers and special characters but no letters c#我想知道字符串中的前3个字符是否是字母? - c# I want to know if the first 3 characters in a string is letter? 匹配任何不是字母的特殊字符(包括下划线,但不包括空格) - Match any special characters (including underscore, but not space) that are not letters 如何编写仅允许字母,数字和特殊字符(仅中间出现)的正则表达式 - How to Write a Regular Expression that allows only letters, numbers and special characters only i the middle never in the end 一开始它至少接受 3 个字母,然后在 .net 中接受数字和特殊字符 - the beginning it accepts at least 3 letters and from there numbers and special characters in .net 包含特殊字符的 19 个字符串的正则表达式 - Regex for a 19 character string that includes special characters 如何检测字符串中的特殊字符和数字? - How to detect special characters and numbers in a string? 创建包含空格(字符之间的一个空格)的随机字符串,第一个字符不是空格 - Create random string that includes spaces (one space between characters), and first character is not a space 使用特殊情况获得前140个字符串的字符串 - Get first 140 characters of string with special case 替换特殊字符或特殊字符后跟空格 - Replace special characters or special characters followed by space
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM