import re 
pattern = r"^.*\b(?:cart|order)\b.*|(\b\d{4,12}\b)"

text1 = 'the cart number is 1234 and 4567 that it!'
text2 = "order 12345"
text3 = "credit card is 0000 4567 and 3456"
text4 = "i got 245 dollar"
text5 = "the 4567 and 2345 "

strings = [
    text1,
    text2,
    text3,
    text4,
    text5
]

for string in strings:
    print([s.span() for s in re.finditer(pattern, string, re.M) if s])

