[issue46065] re.findall takes forever and never ends

2021-12-19 Thread Gareth Rees
Gareth Rees added the comment: This kind of question is frequently asked (#3128, #29977, #28690, #30973, #1737127, etc.), and so maybe it deserves an answer somewhere in the Python documentation. -- resolution: -> wont fix stage: -> resolved status: open -> closed

[issue46065] re.findall takes forever and never ends

2021-12-19 Thread Gareth Rees
Gareth Rees added the comment: The way to avoid this behaviour is to disallow the attempts at matching that you know are going to fail. As Serhiy described above, if the search fails starting at the first character of the string, it will move forward and try again starting at the second char

[issue46065] re.findall takes forever and never ends

2021-12-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Limit the number of repetitions. For example use "{1,100}" (or what is the expected maximal length of email) instead of "+". -- ___ Python tracker ___

[issue46065] re.findall takes forever and never ends

2021-12-13 Thread Ramzi Trabelsi
Ramzi Trabelsi added the comment: thanks for the answer. Is there any workaround for this ? -- ___ Python tracker ___ ___ Python-bu

[issue46065] re.findall takes forever and never ends

2021-12-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The simplest example is: re.search('a@', 'a'*10) -- ___ Python tracker ___ ___ Python-bugs

[issue46065] re.findall takes forever and never ends

2021-12-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It ends, but it tooks several minutes to complete. It is a limitation of the regular expression implementation in Python. Your input contains a sequence of 588431 characters which match the pattern [a-zA-Z0-9_.+-] not following by '@'. The engine finds the

[issue46065] re.findall takes forever and never ends

2021-12-13 Thread Ned Deily
Change by Ned Deily : -- components: +Regular Expressions nosy: +ezio.melotti, mrabarnett, serhiy.storchaka -ned.deily, ronaldoussoren type: crash -> behavior ___ Python tracker __

[issue46065] re.findall takes forever and never ends

2021-12-13 Thread Ramzi Trabelsi
Change by Ramzi Trabelsi : -- components: -macOS ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue46065] re.findall takes forever and never ends

2021-12-13 Thread Ramzi Trabelsi
New submission from Ramzi Trabelsi : parsing emails from this text took forever and never ends. Here the code and the file res.html is attached. The Behavior is same on Windows 10, 11 and Ubuntu 18.04 CODE: import re pattern_email = r"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]{2,3}"