-1

Basic php regex to find repeated character not working..

$subject = 'rrrr';
var_dump(preg_match("/([a-zA-Z])\1{2,}$/i", $subject));
var_dump(preg_match("/(\w)\1{2,}$/i", $subject));

same seem to be working here : https://regex101.com/r/OCAwi0/2

naxrohan
  • 352
  • 3
  • 15

1 Answers1

0

Try this code, example in link : https://3v4l.org/9MFvm

<?php

$regex = '#([a-zA-z ])\1{2,}$#';
$string = 'rrrr';
preg_match($regex, $string, $matches);
var_dump($matches);
delboy1978uk
  • 12,118
  • 2
  • 21
  • 39