I'm trying to create a regex to match numbers 1-12 for the months of year(where the first digit is optional) and 1-31 for days of the month without appending all the numbers from 1 to 12.(Just imagine memory if this was for 1 - 1million)
pd.Series(["some text8some text","some text13some text", "05"]).str.extract('(?P<mm>[1][012]|(?:[0])?[1-9])')
Works on the 8 properly but on 13 instead of ignoring it matches to 1. So I tried
pd.Series(["some text8some text","13some text", "05"]).str.extract('(?P<mm>[1][012]|(?:[0])?[1-9][^0-9])')
But it forces me to have a character after 8 otherwise does not match.
Could someone please help with this regex negation which is forcing me to have a character after 8 to match?
The desired output for this is
0: 8
1: Nan
2: 5
Since there is no whitespace, word boundary will not work thus forcing us to use regex-negation.