Skip to content

Instantly share code, notes, and snippets.

@corneliouzbett
Last active March 17, 2019 19:58
Show Gist options
  • Save corneliouzbett/735fcdaad7a443cd90812f340a827a0c to your computer and use it in GitHub Desktop.
Save corneliouzbett/735fcdaad7a443cd90812f340a827a0c to your computer and use it in GitHub Desktop.
#A RegEx, or Regular Expression, is a sequence of characters that forms a search pattern.
# RegEx can be used to check if a string contains the specified search pattern
import re
text = "The above code is for dummies like you"
# Check if the string starts with "The" and ends with "Spain":
x = re.search("^The.*code$", text)
if (x):
print("Yes we have a match")
else
print("Don't have a match")
# output = Don't have a match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment