firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.24k stars 199 forks source link

Python substitute code generator bug #1924

Closed nilsherzig closed 1 year ago

nilsherzig commented 1 year ago

Bug Description

Looks like the python substitute generator uses $n to reference capture groups.

It generated this sub string for me: subst = "\"<a href=\"$2.md.html\">$2</a>\"" this string doesn't work in 3.10.7.

This works for me subst = r"\"<a href=\"\2.md.html\">\2</a>\"" using a raw string and \ instead of $

nilsherzig commented 1 year ago

@Genericreqd wdym?

firasdib commented 1 year ago

The code generator doesn't translate the regex between flavors, you'll have to pick the correct flavor from the UI and adjust your regex accordingly first.