Skip to content

Instantly share code, notes, and snippets.

@deeTEEcee
Created July 20, 2022 23:38
Show Gist options
  • Save deeTEEcee/17605e8c2646fc054d3175ec25b9270f to your computer and use it in GitHub Desktop.
Save deeTEEcee/17605e8c2646fc054d3175ec25b9270f to your computer and use it in GitHub Desktop.
Basic Regex Check
import re
text_list = [
"P1:field1",
"P1:field2"
"P2:field1"
"P2:field2",
"P3:field1",
"P3:field2",
"P4:field1",
"P5:field1",
"p2:field1"
"endingwith P1:",
"endingwith P2:",
"endingwith P3:"
"other-field"
]
pattern = re.compile("[P|p][^1-2]:")
for text in text_list:
if pattern.match(text):
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment