Aunsiels / pyformlang

A python library to manipulate formal languages and various automata
https://pypi.org/project/pyformlang/
MIT License
45 stars 10 forks source link

Fix '\\' escape bug in PythonRegex #17

Closed marcotcr closed 1 year ago

marcotcr commented 1 year ago

Python regex has a bug such that the following code return (False, False):

import pyformlang
import pyformlang.regular_expression
r = pyformlang.regular_expression.PythonRegex('.*')
r.accepts(']'),r.accepts('\\')

The problem is that '\' is in list(string.printable), and thus you have to escape it (otherwise it messes up the join). This PR fixes the above.

Aunsiels commented 1 year ago

Thank you for your contribution! I will add a new test with your example.