AF
def get_pattern(text, regobj):
matches = re.findall(text, regobj)
regexp_str = str()
regexp_str = "|".join(matches)
pattern = re.compile(regexp_str)
return pattern
Size: a a a
AF
def get_pattern(text, regobj):
matches = re.findall(text, regobj)
regexp_str = str()
regexp_str = "|".join(matches)
pattern = re.compile(regexp_str)
return pattern
AF
AF
re.compile('[A-Z]\\S* |\\S*[aeiou]')получаем такое
re.compile('Lorem |ipsu|dolo|si|ame|Hello |wo')
AS
"a"*n
и шаблон "a"
будет там повторён n разAF
AF
EZ
for
какой-то? чо не "|".join(matches)
просто?AS
AF
EZ
def get_pattern(text, regobj):
return re.compile("|".join(re.findall(text, regobj)))
AF
AS
EZ
re.compile
оптимайзит там что угодноAF
AF
PS
PS
AF