Ok so I am trying to group past the 9th backreference in notepad++. The wiki says that I can use group naming to go past the 9th reference. However, I can't seem to get the syntax right to do the match. I am starting off with just two groups to make it simple.
Sample Data
1000,1000
Regex.
(?'a'[0-9]*),([0-9]*)
According to the docs I need to do the following.
(?<some name>...), (?'some name'...),(?(some name)...) Names this group some name.
However, the result is that it can't find my text. Any suggestions?
A group is a part of a regex pattern enclosed in parentheses () metacharacter. We create a group by placing the regex pattern inside the set of parentheses ( and ) . For example, the regular expression (cat) creates a single group containing the letters 'c', 'a', and 't'.
A backreference in a regular expression identifies a previously matched group and looks for exactly the same text again. A simple example of the use of backreferences is when you wish to look for adjacent, repeated words in some text. The first part of the match could use a pattern that extracts a single word.
If your regular expression has named capturing groups, then you should use named backreferences to them in the replacement text. The regex (?' name'group) has one group called “name”. You can reference this group with ${name} in the JGsoft applications, Delphi, .
. Your regex starts with (?= (ensure that you can see, but don't consume) followed by . * (zero or more of any character).
You can simply reference groups > 9 in the same way as those < 10
i.e $10 is the tenth group.
For (naive) example:
String:
abcdefghijklmnopqrstuvwxyz
Regex find:
(?:a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)
Replace:
$10
Result:
kqrstuvwxyz
My test was performed in Notepad++ v6.1.2 and gave the result I expected.
Update: This still works as of v7.5.6
SarcasticSully resurrected this to ask the question:
"What if you want to replace with the 1st group followed by the character '0'?"
To do this change the replace to:
$1\x30
Which is replacing with group 1 and the hex character 30
- which is a 0
in ascii.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With