import re s = "1234|Google | Alphabet|pest||pp| |||r"print(re.split(r"\|(?!\s)|(?<!\s)\|", s))
Standard input is empty
['1234', 'Google | Alphabet', 'pest', '', 'pp', ' ', '', '', 'r']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!