fork download
  1. import re
  2.  
  3. sentences = ["'Teacher who was jailed after classroom row over transgender pupil and refusing to 'call a boy a girl' will be joined in prison by his father after courtroom scuffle",
  4. "Did you see Cress' haircut?.",
  5. "This 'thing' hasn't a really bad habit, you know?.",
  6. "'I bought this for $30 from Best Buy it's. What a waste of money! The ear gels are 'comfortable at first, but what's after an hour."]
  7.  
  8. for s in sentences:
  9. # Remove the specified characters
  10. # new_s = len(re.findall(r"""'(?!(?<! ')[ts])""", s))
  11. new_s = len(re.findall(r"""'[(?<!s)]'|'(?!(?<! ')[tsmlvr])""", s))
  12.  
  13. # Deal with the final dot
  14. print(new_s)
  15.  
Success #stdin #stdout 0.15s 15536KB
stdin
Standard input is empty
stdout
3
1
2
2