Check three or more consecutive identical characters or numbers | Python3 program to check three or more consecutiveidentical characters or numbers using regular expression ; Function to check three or more consecutiveidentical characters or numbers using regular expression ; Regex to check three or more consecutive identical characters or numbers ; Compile the ReGex ; If the string is empty return false ; Return if the string matched the ReGex ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 : ; Test Case 5 :
import re NEW_LINE def isValidGUID ( str ) : NEW_LINE INDENT regex = " \\b ( [ a - zA - Z0-9 ] ) \\1\\1 + \\b " NEW_LINE p = re . compile ( regex ) NEW_LINE if ( str == None ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( re . search ( p , str ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT str1 = " aaa " NEW_LINE print ( isValidGUID ( str1 ) ) NEW_LINE str2 = "11111" NEW_LINE print ( isValidGUID ( str2 ) ) NEW_LINE str3 = " aaab " NEW_LINE print ( isValidGUID ( str3 ) ) NEW_LINE str4 = " abc " NEW_LINE print ( isValidGUID ( str4 ) ) NEW_LINE str5 = " aa " NEW_LINE print ( isValidGUID ( str5 ) ) NEW_LINE