开发者

Match if several identical characters in a string

I would like to match if a string contains more than 1 identical character, for example : Using PHP preg_match or similar function.

the character would be "-"

Something-or other : no match

Test-tes-t : match

Basically what 开发者_高级运维I want to do is disallow the use of more than 1 "-" in a user input.


Isn't just substr_count($text, '-') > 1 enough?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜