Answer by Jan for Match a specific number of digits not preceded or followed...
You could even generalize it with a function:import restring = "11a2ee22b333c44d5e66e777e8888"def numbers(n,m): rx = re.compile(r'(?<!\d)(\d{'+'{},{}'.format(n,m) +'})(?!\d)') return...
View ArticleAnswer by Shenglin Chen for Match a specific number of digits not preceded or...
lookaround regex,\d{2,3} means 2 or 3 digits, (?=[a-z]) means letter after digits. In [136]: re.findall(r'(\d{2,3})(?=[a-z])',string)Out[136]: ['11', '22', '333', '44', '66', '777']
View ArticleAnswer by Zero Piraeus for Match a specific number of digits not preceded or...
Note: The result you show in your question is not what I'm getting:>>> import re>>> re.findall(u'(?:\D|^)(\d{2,3})(?:\D|$)',u'11a2ee22b333c44d5e66e777e8888')[u'11', u'22', u'44',...
View ArticleMatch a specific number of digits not preceded or followed by digits
I have a string:string = u'11a2ee22b333c44d5e66e777e8888'I want to find all k consecutive chunks of digits where n <= k <= m. Using regular expression only:say for example n=2 and m=3 using...
View Article
More Pages to Explore .....