fork download
  1. import re
  2. text = "'text... 'some quotes', there's none'. three 'four' can't, '2'4', '_'_', 'l'école'"
  3. print( re.sub(r"(?!\b'\b)'", "", text) )
  4. print( re.sub(r"'(?!(?<=[a-zA-Z]')[a-zA-Z])", "", text) )
  5. print( re.sub(r"'(?!(?<=[^\W\d_]')[^\W\d_])", "", text) )
Success #stdin #stdout 0.02s 9528KB
stdin
Standard input is empty
stdout
text... some quotes, there's none. three four can't, 2'4,  _'_, l'école
text... some quotes, there's none. three four can't, 24,  __, lécole
text... some quotes, there's none. three four can't, 24,  __, l'école