Reputation: 644
for instance, change the following(multi-line):
hello-a
hello-b
hello-c
hello-d
to
hello-1
hello-2
hello-3
hello-4
I just find regex "hello-[a-zA-Z]*" to match "hello-?", but can't find a replacement replace them to auto-added numbers.
Upvotes: 0
Views: 1037
Reputation: 1290
I'm not yet sure about for Notepad++
, but Textpad
, you use:
\i(n) -or-
\i(n,) -or-
\i(n,m)
in your case \i(1)
or just \i
.
Also, in the example regex you provided:
hello-[a-zA-Z]*
It would match (as you have mentioned):
hello-a
hello-b
hello-c
hello-d
but it would also match "hello-a...a" ("hello-" followed by one or more alpha):
hello-aa
hello-abc
hello-tuvwxyz
and it would also match "hello-" (when followed by nothing or followed by non-alpha):
hello-
hello-#
hello-1
So, if this is as you intended it, the Regex search would be:
(hello-)[a-zA-Z]*
If you want to match "hello-" followed only-one alpha, the Regex search would be:
(hello-)[a-zA-Z]
If you want to match "hello-" followed one-or-more alpha, the Regex search would be:
(hello-)[a-zA-Z]+
For all these, the Regex replacement would be:
\1\i(1)
\i[(n[,m])]
n is the starting point, and m is the increment amount.
\i(100,5) --> 100,105,110...
If parenthesis are not specified (\i by itself), this is the same as \i(1) or \i(1,1)
\i --> 1,2,3...
If parenthesis are specified...
If n is omitted then n defaults to 0.
\i(,1) --> 0,1,2...
\i(,100) --> 100,200,300...
If ",m" is omitted, then m defaults to 1.
\i(1) --> 1,2,3...
\i(101) --> 101,102,103...
If both n and m are omitted [\i() by itself], this is the same as \i(0) or \i(0,1)
\i() --> 0,1,2...
Note: in order for \i
to work properly, you have to Replace all
on the entire document (or the entire selection).
There is no ending
parameter. \i
will keep incrementing the replacement until all matches have been replaced.
Notepad++
.
Upvotes: 2