【发布时间】:2016-03-23 07:44:59
【问题描述】:
我知道这对你们来说非常简单,但我正在摸索寻找匹配以下字符串的正则表达式。尝试过不同的reg ex,但每次都失败。下面是需要匹配/不匹配的字符串。
S__ATHEESH – not match
S_A_T_HEESH – match
S’_ATHEESH – match
S’’ATHEESH – not match
S-A_THEESH - match
这是要求
a. A name can have the special characters – space, apostrophe, underscore and hyphen.
b. There can be more than 1 special character in a name, but same special character cannot repeat more than once continuously.
c. There should be minimum 2 characters entered in the name field
我有以下 reg ex,需要修改
^([a-zA-Z]+[ _'-])*[a-zA-Z]+$
感谢您的帮助。
【问题讨论】:
-
根据您的要求,任何字符串都不应该匹配,因为所有字符串都有连续重复的字符'E'
-
@MohitC 关于连续特殊字符的问题
-
您刚刚在标题中说“相同字符”以及要求 2。
-
我刚刚更正了请求 2。
标签: javascript c# angularjs regex