import re

print("[Pp]ython", "Python"))
print("[a-z]way", "The end of the highway"))
print("cloud[a-zA-Z0-9]", "cloudy"))

# put ^ before a character class to search for anything but the given character class
print("[^a-zA-Z]", "This is a sentence with spaces."))

# | as OR operator
print("cat|dog", "I like dogs."))
print(re.findall(r"cat|dog", "I like both cats and dogs."))
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter