0

I tested my regex with Regex101 already, but when I tried in Python 3.5.1 it returns None

Here's my Regex101

And here's my Python code. Not sure if I miss anything.

Python 3.5.1 |Anaconda 2.4.0 (x86_64)| (default, Dec  7 2015, 11:24:55)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> p = re.compile('([01]?[0-9]+:?[0-9]*(?:[AP]M)?)-([01]?[0-9]+:?[0-9]*(?:[AP]M)?)', re.MULTILINE)
>>> m = p.match('NO PARKING (SANITATION BROOM SYMBOL) 7AM-7:30AM EXCEPT SUNDAY')
>>> print(m)
None
>>>
ndnenkov
  • 35,425
  • 9
  • 72
  • 104
toy
  • 11,711
  • 24
  • 93
  • 176

1 Answers1

6

The problem is that match will search from the start of the string. Use search instead.

ndnenkov
  • 35,425
  • 9
  • 72
  • 104