0

What is the regex to check if a character occurs more than 2 times in a string? Example: “aab” is allowed, but not “aaa” or “aaba”.

Is there a way to make it match only on valid inputs (when there are less than 3 repeating characters) so that the preg_match() function returns 1 for valid input (with less than 3 repeating characters) and else 0?

Thanks!

Anonymous Asked question May 14, 2021