Nov-13-2023, 01:29 PM
hi
in below code( code belongs to a site that its address is in beginning of the code):
thanks
in below code( code belongs to a site that its address is in beginning of the code):
# from:https://www.geeksforgeeks.org/regular-expressions # -python-set-1-search-match-find/ # A Python program to demonstrate working # of re.match(). import re # a sample function that uses regular expressions # to find month and day of a date. def findMonthAndDate(string): regex = r"([a-zA-Z]+) (\d+)" match = re.match(regex, string) if match == None: print ("Not a valid date") return print ("Given Data: %s" % (match.group())) print ("Month: %s" % (match.group(1))) print ("Day: %s" % (match.group(2))) # Driver Code findMonthAndDate("Jun 24") print("") findMonthAndDate("I was born on June 24")why the result of the match in the second call of findMonthAndDate is None? the statement June 24 is in two calls, and I think it matches to defined pattern in the function. if I think wrong, how can the pattern be changed to print June 24 for the second call of the function?
thanks