brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser
BSD 3-Clause "New" or "Revised" License
6.39k stars 511 forks source link

re behaviour #2487

Closed zokrezyl closed 1 month ago

zokrezyl commented 2 months ago

Hi,

Brython is amazing! Discovered a little issue. Wanted to run python rich in brython, but the initialization fails due to re problems.

color = "rgb(249,38,114)"
RE_COLOR = re.compile(
    r"""^
\#([0-9a-f]{6})$|
color\(([0-9]{1,3})\)$|
rgb\(([\d\s,]+)\)$
""",
    re.VERBOSE,
)
m = RE_COLOR.match(color)
print(m)
# output Null

However on python 3.12 it works. (Don't think would behave differently on < 3.12

Regards Z.

zokrezyl commented 2 months ago

in chrome console


import re
RE_SIMPLE = re.compile(r'rgb\(\d+,\d+,\d+\)')
color = 'rgb(249,38,114)'
match = RE_SIMPLE.match(color)
print(match)

works. Is brython using jscript re?

PierreQuentel commented 2 months ago

Thanks for the report @zokrezyl

The example fails with the current release (3.12.4) but not with the current development version. Can you check ?