Fable
Fable copied to clipboard
[Python] Regex lookbehind
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
:
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