fork download
  1. import re
  2. text = r'ced"|"ms|n"|4|98'
  3. pattern = r'"?\|(?!(?:(?<=[A-Za-z]\|)|(?<=[A-Za-z]\\\|))(?=[a-zA-Z]))"?'
  4. print( re.split(pattern, text) )
  5. # => ['ced', 'ms|n', '4', '98']
  6. text = r'ced"|"ms\|n"|4|98'
  7. print( re.split(pattern, text) )
  8. # => ['ced', 'ms\\|n', '4', '98']
Success #stdin #stdout 0.03s 9384KB
stdin
Standard input is empty
stdout
['ced', 'ms|n', '4', '98']
['ced', 'ms\\|n', '4', '98']