Created
July 20, 2022 23:38
-
-
Save deeTEEcee/17605e8c2646fc054d3175ec25b9270f to your computer and use it in GitHub Desktop.
Basic Regex Check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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