Finding Acronyms Using Regex In Python -


i'm trying use regex in python match acronyms separated periods. have following code:

import re test_string = "u.s.a." pattern = r'([a-z]\.)+' print re.findall(pattern, test_string) 

the result of is:

['a.'] 

i'm confused why result. know + greedy, why first occurrences of [a-z]\. ignored?

the (...) in regex creates group. suggest changing to:

pattern = r'(?:[a-z]\.)+' 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -