0

re error - multiple repeat

Hey, guys. I have some troubles with my regex. so, here is my code: pat1 = r"(interface\sVlan.{1,4}*ip\shelper-address\s)((25[0-5]|2[0-4]\d|[01]?\d\d?)(\.(?!$)|$)){4}(\r\nip\sdhcp\srelay\sinformation\spolicy\skeep){0,1}" otxt = str(re.findall(pat1, text)) But when i try to run this code it crashes with errors: File "*/test_scr.py", line 5, in change_vlan otxt = str(re.findall(pat1, text)) File "*/re.py", line 177, in findall return _compile(pattern, flags).findall(string) File "*/re.py", line 242, in _compile raise error, v # invalid expression sre_constants.error: multiple repeat What does those errors mean? And how can I fix it?

28th Mar 2018, 2:07 PM
ПаĐČДл ЛуĐșашОĐș
ПаĐČДл ЛуĐșашОĐș - avatar
1 Answer
+ 1
I think it's because you use "str" function on "re.findall(pat1, text)" but this return a list and there is no "str" function on lists. What do you want to do with "str(list)" ??
11th Jun 2018, 1:48 PM
Julien Lord Maring
Julien Lord Maring - avatar