Regex Extract all substrings that meet the following criteria:
first 4 chars are numbers and substring ends with number or letter
15 or 18 chars long
If there are 2 substrings that meet the criteria, just return the first one
df1 = pd.DataFrame(data ={"Messy_IDS":["Looking for ID : 7010M000002N8c5T7A","5634M000002N8c5T7A,7010M000002N8c5T7A","https://website.com/12340000000f5F5"], "Desired_Output":["7010M000002N8c5T7A","5634M000002N8c5T7A","12340000000f5F5"]})
df1
Messy_IDS Desired_Output
0 Looking for ID : 7010M000002N8c5T7A 7010M000002N8c5T7A
1 5634M000002N8c5T7A,7010M000002N8c5T7A 5634M000002N8c5T7A
2 https://website.com/12340000000f5F5 12340000000f5F5