fork download
  1. import re
  2.  
  3. s = "Hi, domain: (foo.bar.com) bye. So long"
  4.  
  5. print(re.findall(r'(?:^|\b)(\w+(?:\.\w+)*|\W+)(?!\.\w)(?=\b|$)', s))
  6.  
  7. print(re.findall(r'(?:^|(?<!\.)\b(?!\.)).+?(?=(?<!\.)\b(?!\.)|$)', s))
Success #stdin #stdout 0.03s 9424KB
stdin
Standard input is empty
stdout
['Hi', ', ', 'domain', ': (', 'foo.bar.com', ') ', 'bye', '. ', 'So', ' ', 'long']
['Hi', ', ', 'domain', ': (', 'foo.bar.com', ') ', 'bye. ', 'So', ' ', 'long']