Python Regex Catch Multi Caps Words And Adjacent Words
I have a regex that does the following: Find a word that has two or more adjacent capital letters A-Z ('multi caps word'); When possible, extend the match to the left and to the r
Solution 1:
Try this:
>>> pattern = r'(?:[a-z\d]+\s*){0,5}(?:[A-Z]+)(?:\s*[A-Z]+)*(?:\s*[a-z]+){0,3}'
>>> re.findall(pattern, str1)
['z z z z z11 AA BB DD f f d', 'gd df sdf ggf we AA ff d f']
Post a Comment for "Python Regex Catch Multi Caps Words And Adjacent Words"