import recontents = 'ST8*010A1~BHT*0019*0 BHT#5*20190114*'new_list = re.split(r'(?<=~)BHT[^A-Za-z0-9 ]', contents)print(new_list)
Standard input is empty
['ST8*010A1~', '0019*0 BHT#5*20190114*']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!