-2

I'm trying to get python regex to match the end of a string (primarily because I want to remove a common section off the end of the string. I have the following code which I think is how the docs describe to do it, but it's not performing as I'm expecting:

input_value = "Non-numeric qty or weight, from 00|XFX|201912192009"
pattern = ", from .*$"
match = re.match(pattern , input_value)
print(match)

The result is None, however I'm expecting to have matched something. I've also tested these values with an online regex tool: https://regex101.com/ using the python flavour, and it works as expected.

What am I doing wrong?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Andy
  • 3,228
  • 8
  • 40
  • 65

1 Answers1

0
match = re.match(".*, from.*$", input_value)

you should use .* infront else it will try to fin exact match

PDHide
  • 18,113
  • 2
  • 31
  • 46