fork download
  1. import re
  2.  
  3. s = "Hello, World! This is a reallly long string"
  4.  
  5. print(re.findall(r'^\S.{0,18}\S\b|\b\S.{0,18}\S$', s))
Success #stdin #stdout 0.03s 9500KB
stdin
Standard input is empty
stdout
['Hello,    World', 'reallly long string']