Regex expression to back reference more than 9 values in a replace?
I'm trying to capture several groups within a string using a regex. However once I reach greater than 9 back-references, they do not replace as I expected.
Eg: This is a bit of a contrived example.
Input string: abcdefghijklmnopqrstwhj
Find What: ^(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)$
Replace With: \10
It doesn't work. I also try $10, \g<10>, \$+10.....but failed. Does EmEditor support back references more than 9?
Currently, EmEditor doesn't support backreferences more than 9. If this is important, I will see if I can improve it.
It's hard to say it's important or not. Most case, 9 is enough. Occasionlly I need more.
For my current case, I use "batch replace all" function to resolve it and get successful.
During looking for help from Google, I saw someone mentioned Notepad++ support more than 9.
Yes please, can I second this request. Also, if at all possible, if named groups could be used as named backreferences for replace, that would be fantastic.
e.g. (Just a simple example but: ideally extended to more than 9 capture groups)
Find: (?<day>\d\d)(?<month>\d\d)(?<year>\d\d\d\d)
Replace: \k<year>\k<month>\k<day>
EmEditor v19.1 beta 1 (19.0.91) supports backreferences more than 9 by using this form: $10, $11, $12, ... We will release it shortly.
ありがとう;Thank You;고맙습니다;谢谢;DANKE.
Thanks for your quick response.
Thanks Yutaka,
$n seems to work great. Is it possible to implement named groups for Find and Replace, if the engine used is Onigmo? From the documentation (https://github.com/k-takata/Onigmo/blob/master/doc/RE), it seems as though it is supported?
e.g: Section 8. Backreferences
\k<name> \k'name' backreference a group with the specified name
The next version supports named capturing group by using this form:
(?<name>expression) and named backreference by using this form: \k<name>.
Thank you!8 posts in this topic