开发者

Match if several identical characters in a string

开发者 https://www.devze.com 2023-04-10 16:52 出处:网络
I would like to match if a string contains more than 1 identical character, for example : Using PHP preg_match or similar function.

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

精彩评论

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