programming-examples/python/Regular_Expression/Remove words from a string of length between 1 and a given number.py
2019-11-15 12:59:38 +01:00

6 lines
204 B
Python

def is_decimal(num):
import re
text = "The quick brown fox jumps over the lazy dog."
# remove words between 1 and 3
shortword = re.compile(r'\W*\b\w{1,3}\b')
print(shortword.sub('', text))