[issue38660] Checking if two regexes are equal should test if they are functionally equivalent

2020-12-07 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue38660] Checking if two regexes are equal should test if they are functionally equivalent

2020-12-06 Thread Ronald Oussoren
Ronald Oussoren added the comment: https://math.stackexchange.com/questions/46975/how-to-prove-two-regular-expressions-are-identical-in-mathematical-way contains some references to proofs that checking if two regular expressions are equivalent is PSPACE-complete. Another answer in that

[issue38660] Checking if two regexes are equal should test if they are functionally equivalent

2019-11-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Python's regular expressions are not actually regular. Lookarounds and groups make things more complex. Even it it is possible to build an ambiguous graph, its size and the time of building can be too large for practical use. Dealing with unicode is only

[issue38660] Checking if two regexes are equal should test if they are functionally equivalent

2019-11-01 Thread Борис Верховский
Борис Верховский added the comment: I saw two Python regexes, one derived from a regex in the standard library. There was a comment saying that they're interchangeable and I wanted to check if they were actually the same without having to read what all the regex symbols mean. Plus a true

[issue38660] Checking if two regexes are equal should test if they are functionally equivalent

2019-11-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: These two regexes are not the same. >>> re.compile('([-_.a-zA-Z0-9]+)').match('ä') >>> re.compile(r'([-\w.]+)').match('ä') As Ammar said checking that two regexes always matches the same is very difficult problem. It is the problem of determining if two

[issue38660] Checking if two regexes are equal should test if they are functionally equivalent

2019-11-01 Thread Ammar Askar
Ammar Askar added the comment: The notion of equivalent regular expressions does exist but is way more complicated than the simple example you described. For example: r"a|b" is the same as r"[ab]", r"^aa*$" is the same as r"^a+$" Implementing this properly would probably require a

[issue38660] Checking if two regexes are equal should test if they are functionally equivalent

2019-11-01 Thread Борис Верховский
New submission from Борис Верховский : re.compile('([-_.a-zA-Z0-9]+)') == re.compile(r'([-\w.]+)') should return True because those are the same regex (\w is a-z, A-Z, 0-9 and the underscore). If you want to check if two regexes are identical you would compare the original strings, before