I have a bunch of strings of the format "Initials - Month - Year" which i want to split. However, the exact format is not consistent due to user input. Some examples:
'AA-JAN17'
'AA- JAN 17'
'AA-JAN-17'
'AA - JAN - 17'
'AA - 01 - 2017'
What I want is ['AA', 'JAN', '17']
. Converting 01 to JAN or 2017 to 17 is trivial.
I can split on a hyphen and remove spaces by doing
st = 'AA-JAN-17'
list = [s.strip() for s in st.split('-')]
which will work, except for the first and second example where there is no hyphen between month and year. I could probably split on both letters/numbers and on the hyphen but I'm not sure how to do this. This could probably be done with regex but I'm not familiar with that at all.
I accept that there are any number of ways the string could be entered but if there's something that can work for all the examples above then that will be good enough for most cases.