fork download
  1. import re
  2. p = re.compile(r'(?=(~[^\s~]+~))')
  3. test_str = " ~*_abc~xyz~ ~123~"
  4. print(p.findall(test_str))
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
['~*_abc~', '~xyz~', '~123~']