Learn Before
Code

RegEx + Code Example

import re txt = "Python is the coolest language!" #Check if txt contains "c" #followed by 1 or more "o" characters: x = re.findall("co+", txt) print(x) if x: print("Match!") else: print("No match") #Since txt contains the word "coolest" with "c" followed by 2 "o" characters, #it will print "Match!"

0

1

Updated 2021-08-24

Tags

Python Programming Language

Data Science