Regular Expressions (RegEx): ============================ ==> denoted as "RegEx". ==> is a sequence of characters that uses a search pattern to find a string or set of string. ==> RegEx ==> built-in module named as "re" module ==> a collection of files, classes, functions etc. ==> while using the RegEx, we must import this module. Syntax: import re import re s = "Python Fullstack at Ashok IT" m = re.search(r'at',s) m1 = re.search('Fullstack',s) print("The Start Index = ",m.start()) # 17 print("The End Index = ",m.end()) # 18 # range(start,end) ==> range() start to generate value from given "start" value and end with "end" value - 1 print("The Start Index = ",m1.start()) # 17 print("The End Index = ",m1.end()) # 18 =============================================== Meta Characters: ================ \ === import re s = "Ashok.IT" m1 = re.search(r'.',s) print(m1) m1 = re.search(r'\.',s) print(m1) ================================= [] == ex: [abc]==> set of characters [0,7] ==> range [a-d] ==> range of alphabets ==> [abcd] import re s = "The Cat Sat on a wall." p = "[b-r]" # bcdefghijklmnopqr p1 = "[bde]" result = re.findall(p,s) r1 = re.findall(p1,s) print(result) print(r1) =============================== ^ === import re p = r'^The' s = ['The quich brown box','The lazy dog','A quick brown fox'] for i in s: if re.match(p,i): print(i) else: print("Not found") ================================= . === a.b "python" s = "p.t" ==> pyt import re s = "The quick brown fox jumps over the lazy dog" p = r"brown.fox" p1 = r"b.o" m = re.search(p,s) if m: print("Match Found") else: print("No Match found.") print(m) m1 = re.search(p1,s) print(m1) ==================== ? === ex: ab?c import re s = "The quick brown fox jumps over the lazy dog" p = r"b?o" m = re.search(p,s) print(m)