- AuthorPosts
- July 31, 2019 at 8:15 pm #26044DavidParticipant
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: \10It doesn’t work. I also try $10, \g<10>, \$+10…..but failed. Does EmEditor support back references more than 9?
July 31, 2019 at 10:21 pm #26046Yutaka EmuraKeymasterCurrently, EmEditor doesn’t support backreferences more than 9. If this is important, I will see if I can improve it.
July 31, 2019 at 11:17 pm #26047DavidParticipantIt’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.
August 1, 2019 at 9:46 am #26048Mr KTParticipantYes 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>
August 13, 2019 at 2:06 pm #26096Yutaka EmuraKeymasterEmEditor v19.1 beta 1 (19.0.91) supports backreferences more than 9 by using this form: $10, $11, $12, … We will release it shortly.
August 16, 2019 at 6:11 am #26109DavidParticipantありがとう;Thank You;고맙습니다;谢谢;DANKE.
Thanks for your quick response.August 19, 2019 at 8:13 am #26115Mr KTParticipantThanks 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 nameAugust 26, 2019 at 2:38 pm #26121Yutaka EmuraKeymasterThe next version supports named capturing group by using this form:
(?<name>expression)
and named backreference by using this form:\k<name>
.
Thank you! - AuthorPosts
- You must be logged in to reply to this topic.