Created
July 26, 2016 14:53
-
-
Save jkw552403/793837d8f78e4e5d8ce88794dd47fe99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
sent = 'a b c b c c A B C B C C' | |
match = re.search('\w+', sent) | |
while match: | |
word = match.group() | |
sent, count = re.subn(word, '', sent, flags=re.I) | |
match = re.search('\w+', sent) | |
print(word, count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment