How to disable the use of two or more matching symbols in a row?

If there is more than one of the same symbol, e.g.,###, then this text should not be tested, but such #-#-# passes.
How to do it with regexps? Thank you.
March 19th 20 at 08:51
2 answers
March 19th 20 at 08:53
Solution
In the General case, to check for same consecutive characters, you can:
(.)\1

And what programming language?
PHP - Jaydo commented on March 19th 20 at 08:56
<?php
$str = '#-#-#';
echo(preg_match("/(.)\\1/",$str)); //0
echo '<br>';
$str = '###';
echo(preg_match("/(.)\\1/",$str)); //1
?>
- dee.DAmore commented on March 19th 20 at 08:59
March 19th 20 at 08:55
Found this https://stackoverflow.com/questions/1660694/regula...
/(.)\1{1,}/.test("##") > true - there are duplicates, invalid
/(.)\1{1,}/.test("#-#") > false
/(.)\1{1,}/.test("11") > true - there are duplicates, invalid
/(.)\1{1,}/.test("1-1") > false

Find more questions by tags Regular expressionsPHP