Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Python regex to find repetitive word count
import re from collections import Counter text_1 = "Hi, hi Jane! I'm so. So glad to to finally be able to write - WRITE!! - to you!" repeats_1 = re.findall(r'\b(\w+)\b(?=.*\b\1\b)', text_1, re.I) print "actual regex output ===> ", repeats_1 repeats_1 = list(map(str.lower, repeats_1)) c_1 = Counter(repeats_1) print "End result ==>", c_1 text_2 = "Hi KSR?, How are you KSR?, Great KSR? Where are you KSR?" repeats_2 = re.findall(r'\b(\w+)\b(?=.*\b\1\b)', text_2, re.I) print "actual regex output ===> ", repeats_2 repeats_2 = list(map(str.lower, repeats_2)) c_2 = Counter(repeats_2) print "End result ==>", c_2
run
|
edit
|
history
|
help
0
No of Minutes in 7 weeks
python
Epic
Problem Name: single_digit
gvgvg
PyRangeArg
Crypto 123 - MD5
Problem: Binary
Problem: rstring
PyAddBook