I want to extract numbers from strings that do not start with order and cart and that should not end with dollar.
I have the following code:
import re
pattern = "(^.*\b(?:cart|order)\b.*)(\b\d{2,12}\b)"
text1 = ('the cart number is 1234 and 4567 that it!')
text2 = ("order number note down 12345")
text3 = "credit card is 0000 and 3456"
text4 = "the 4567"
text5 = "i got 245 dollar"
result = re.search(pattern, text4)
print(result)
Expected output match
text3 0000 3456
text4 4567
Can we achieve expected output by passing one example at a time using re module?