import re
def date_to_internal_stored_format(input_text, identify_only_4_digit_years = False, limit_numbers_immediately_after_date = True):
#grupo de captura para fechas en donde el año tiene si o si 4 digitos
if (identify_only_4_digit_years == True):
if(limit_numbers_immediately_after_date == True):
date_capture_pattern = r"([12]\d{3}-[01]\d-[0-3]\d)(\D*?)"
elif(limit_numbers_immediately_after_date == False):
date_capture_pattern = r"([12]\d{3}-[01]\d-[0-3]\d)"
input_text = re.sub(date_capture_pattern, lambda m: m.group().replace("-", "_-_", 2), input_text)
return input_text
input_text = "el dia 2022-12-2344 o sino el dia 2022-09-23 10000-08-23"
input_text = date_to_internal_stored_format(input_text, False, True)
print(repr(input_text))
Why doesn't the limit imposed behind work so that after the last number of the date there can be no more numbers to be considered a group that must be captured?
I need this output where 2022-12-23
is not captured I need this output where this is not captured, since there are more than 2 digits at the end of the date (\D*?)
'el dia 2022-12-2344 o sino el dia 2022_-_09_-_23 10000_-_08_-_23'