[llvm] [Support] Add `\{<ref>}` backreferences in Regex::sub() (PR #67220)

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 22:54:10 PDT 2023


igorkudrin wrote:

> Worth using a syntax that matches something existing, like the Python one seems close? Or do we already diverge in a bunch of ways for the syntax in substitutions that there's no real consistency to be gained?

I'm not sure what syntax the original author was trying to mimic, although Python's looks very close. I didn't go this way because supporting the `\\g<num>` notation requires a bit more code and, as you can see, each implementation uses its own variant anyway. This particular syntax from Python looks very specific, so I supposed that implementing it might mislead a developer into thinking that other features are also supported; I preferred to stick with something that looks more general. Anyway, I have no objection to implementing any other variant as long as it solves the problem. What is your preference?

https://github.com/llvm/llvm-project/pull/67220


More information about the llvm-commits mailing list