Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Regex lookbehind #3918

Open
HLWeil opened this issue Oct 2, 2024 · 0 comments
Open

[Python] Regex lookbehind #3918

HLWeil opened this issue Oct 2, 2024 · 0 comments

Comments

@HLWeil
Copy link

HLWeil commented Oct 2, 2024

Description

Using lookbehind patterns in regex fails for python.

Repro code

open System.Text.RegularExpressions

let positiveLookbehind = """(?<=A).*"""

Regex(positiveLookbehind)

let negativeLookbehind = """(?<!A).*"""

Regex(negativeLookbehind)

Transpile to python and run.

Expected and actual results

Regex should be created, but fails with:

Traceback (most recent call last):
  File "C:\Users\HLWei\Downloads\FableTesting\output\abc_.py", line 5, in <module>
    create(positive_lookbehind)
  ...
re.error: missing >, unterminated name at position 4

This is caused by the following code in Fable reg_exp.py:

image

Which was probably originally added because of the different Regex syntax for grouping constructs.

Related information

  • Fable version: 4.22.0
  • Operating system: Windows 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant