You can also try this template using JavaScript.
(\w)\1{2,}
and you can check it on jsfiddle too
JavaScript code is as follows:
jQuery(document).ready( function($) { $('#input').on( 'keyup', function() { var $regex = /(\w)\1{2,}/; var $string = $(this).val(); if($regex.test($string)) {
Where $('#input') selects a text field with input identifier. Also with {2,} in the regex pattern you can control the length if duplicate characters. If you change Example 2 to 4 , the pattern will match 5 repeated characters or more.
source share