Closed juliangall closed 1 year ago
Hello @juliangall,
The code generator does not make editorial changes your input - if you type $1-
it'll leave it as such. If you type up an invalid regex, it'll still be invalid in the code example as well. The code generator is meant to give a quick example on how to use said regex in code.
That being said \g<1>-
is valid as a replacement string if you select Python as the active flavor/regex engine.
Please let me know if this helps.
Thanks. I had assumed the selection of language in the Code Generator was the only option. I now see that selecting the active flavor is the way to go.
Bug Description
When specifying that a capturing group is included in the output, the Python code generator shows $1, when what is needed is \g<1>
Reproduction steps
Regex
([a]+)([a-z])
Test Stringaabaaacaaaad
Substitution$1-
The output in the UI is shown correctly as
aa-aaa-aaaa-
However, the code generated for Python has:
Expected Outcome
The correct value for the substitution string should be:
Testing in Colab with the $1 puts the actual string "$1" into the output ("$1-$1-$1-"), and not the captured group. Using the \g form works correctly.
Browser
Chrome 108.0.5359.124
OS
MacOS Ventura 13.1