Advertisement
simeonshopov

Find Occurrences of Word in Sentence

Feb 21st, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.15 KB | None | 0 0
  1. import re
  2.  
  3. text =  input()
  4.  
  5. word = input()
  6.  
  7. regex = f'(^| )\\b{word}\\b'
  8.  
  9. count =  re.findall(regex, text, flags=re.IGNORECASE)
  10.  
  11. print(len(count))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement