Articles → Python → Or Operator In Regular Expression In Python
Or Operator In Regular Expression In Python
Purpose
Example
import re
pattern = "^\d|\d$"
text1 = r"sdasdasd345"
text2 = r"111sdasdasd"
print("text1 ends with number:", re.search(pattern, text1))
print("text2 ends with number:", re.search(pattern, text2))
Output