I have a program in which the user can enter a string and have the date in the string. I am using RegEx to match \d+\/\d+\/\d+ to extract the date from the string but for some reason in my test case, only the last entry is able to work
import datetime
import re
dateList = []
dates = ["Foo (8/15/15) Bar", "(8/15/15)", "8/15/15"]
reg = re.compile('(\d+\/\d+\/\d+)')
for date in dates:
matching = reg.match(date)
if matching is not None:
print date, matching.group(1)
else:
print date, "is not valid date"
returns
Foo (8/15/15) Bar is not valid date
(8/15/15) is not valid date
8/15/15 8/15/15
Is there something wrong with my RegEx? I tested it with RegEx101.com and it seemed to work fine