Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyRegFindFull
#python 3.6.9 #PyRegFindFull #this code is created by Rezaul Hoque on February 23,2022; #contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; import re print("Python findall() example: \n") a = "No ant in Antarctica and another annulation of the search " pick = r'(an(\w+))' fits = re.findall(pick,a, re.IGNORECASE) print(fits) print("Python fullmatch() vs search() example: \n") str = 'February 23, 2022' pick2 = '\d{2}' match = re.fullmatch(pick2,str) if match is not None: print(match.group()) match = re.search(pick2,str) if match is not None: print(match.group()) #fullmatch() vs match() print("Python fullmatch() vs match() example: \n") pick3 = 'February' match2= re.fullmatch(pick3, str) if match2 is not None: print('fullmatch:', match2.group()) match2 = re.match(pick3, str) if match2 is not None: print('match:', match2.group()) #fullmatch() for id check print("Python fullmatch() for id check: \n") def id_OK(a: str) -> bool: pat = r'[A-Za-z0-9._%+-]\s\d{3}' if re.fullmatch(pat, a) is None: raise ValueError(f'The {a} is not a valid id') return True if __name__ == '__main__': try: if id_OK('P 369'): print('The id is valid') except ValueError as e: print(e)
run
|
edit
|
history
|
help
0
PyGen
sainik
PyNamedTuple
lesson3 part3
PyTeleAbs
E
Metric failed
factorial.py
Guru
gauss elimination determinant calculator