fork(1) download
  1. import re
  2. strs = ['hello-world', r'hello;world ', r'he(llo)(w|o rld)', r'hello\;world',r'hello\-world ']
  3. for s in strs:
  4. res = re.findall(r'''(?:\\.|[^\s"'();|&\\])+''', s)
  5. for val in res:
  6. print(val)
  7. print("-------------")
Success #stdin #stdout 0.04s 9500KB
stdin
Standard input is empty
stdout
hello-world
-------------
hello
world
-------------
he
llo
w
o
rld
-------------
hello\;world
-------------
hello\-world
-------------