Advertisement
DiYane

Find Occurrences of Word in Sentence

Sep 27th, 2023
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.17 KB | None | 0 0
  1. import re
  2.  
  3. some_string = input()
  4. searched_word = input()
  5. pattern =fr'\b{searched_word}\b'
  6. mathes = re.findall(pattern, some_string, flags= re.I)
  7.  
  8. print(len(mathes))
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement