I’m trying to make a regex to find numbering between 1 and 3 digits, but I don’t want it to match numbers included in years (e.g. “202” in “2024”). The idea is to rename files in a uniform way using python, e.g. Title_year_number_month. I use the regex to find each part and then assemble them with a function.
For example, in this string, where each separate part mean Title-numbering-month-year :
“APUDNSLL-22-Nov-2022” where I would like to isolate 22 (numbering) but not parts of 2022 (year). I would not like it to return 202, 022, 20, etc.
Another example, where parts mean Title-month-year-numbering :
“CHUATDN_Sept_2022_19”, here I would like to isolate 19 (numbering) but not parts of 2022 (year).
I’ve tried serveral regex in regex101, here’s a list :
(?<!20d{2})(?:nos*)?(d{1,3})(?!d)
(?<!20)(?:nos*)?(d{1,3})(?!d)
(?<!d)(?:nos*)?(d{1,3})(?!d)
(?<!b20d{2}b)(?:nos*)?(d{1,3})(?!d)
(?:nos*)?(d{1,3})(?!20d{2})(?!d)
b(?:nos*)?(d{1,3})b
Is there a way to exclude years from finding a number ?
5