Hi, what would be the regex split I should use to get the date from this path?
I modified the path for illustration purposes. I would like to have 01-31-2023. Thank you!
C:\Users\MESSI\OneDrive - Inter\Documents\Messi L\MIB\MIB-2022 for 2023\2023\Player Count\Player Count for Team Mgmt 01-31-2023.xlsx
based on the structure of your path we expect three segments - before the date, the date, and after the date. That’s why the expression contains three subgroups ()()()
the first and the last group use (.?): . means any character and ? means match that any character as many times (until you hit the next group) - that means the first (.?) selects everything until the date and the second (.?) everything after the date
the middle group uses \d which matches any digit 0-9 followed by {2) which means, find any too consecutive digits. the “-” in-between means match a dash and at the end there’s another \d for digits with {4} to indicate 4 numbers are required.
Hope that makes sense.
regex101 explains this probably a bit better (in the top right corner marked in red square):