Python regex to find sequences of one upper case letter followed by lower case letters Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Write a Python Program to find sequences of one upper case letter followed by lower case letters. If found, print 'Yes', otherwise 'No'. Examples:Input : GeeksOutput : YesInput : geeksforgeeksOutput : NoPython regex to find sequences of one upper case letter followed by lower case lettersUsing re.search() To check if the sequence of one upper case letter followed by lower case letters we use regular expression '[A-Z]+[a-z]+$'. Python import re def findSequence(text): # regex pattern pattern = '[A-Z][a-z]+' # Use re.search to find any match if re.search(pattern, text): return 'Yes' else: return 'No' # Driver program if __name__ == "__main__": word = 'geeAkAA55of55gee4ksabc3Ar2x' print(findSequence(word)) word = 'Geeks' print(findSequence(word)) word = 'geeksforgeeks' print(findSequence(word)) Output:YesYesNoTime complexity: O(n), where n is length of string.Auxiliary Space: O(1)Find those sequences of one upper case letter followed by lower case lettersTo find and print all sequences of one uppercase letter followed by lowercase letters in the given text we can use the re.findall() function. Here's how we can do it: Python import re def findSequences(text): #regex pattern pattern = r'[A-Z][a-z]+' return re.findall(pattern, text) # Driver program if __name__ == "__main__": word = 'geeAkAA55of55gee4ksabc3Ar2x' print(findSequences(word)) word = 'Geeks' print(findSequences(word)) word = 'geeksforgeeks' print(findSequences(word)) Output:['Ak', 'Ar']['Geeks'][]Time Complexity: O(n) where n is the length of the input text.Auxiliary Space Complexity: O(k) where k is the number of matches found. Comment More infoAdvertise with us Next Article Must Do Coding Questions - Topic-wise S Smitha Dinesh Semwal Follow Improve Article Tags : Python Python Programs python-regex Python Regex-programs Practice Tags : python Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like