Add Increment Number (part 2)
-
So, I have this:
bebe-55
bebe-55
bebe-55I made a regex so to add number 1-3, before each line:
1-bebe-55
2-bebe-55
3-bebe-55Solution very good, but…:
FIND:
\A(bebe-55)(?:\R\1){2}\z
REPLACE:1-\1\n2-\1\n3-\1Or this:
FIND:
\A(.*)\R(.*)\R(.*)\R?\Z
REPLACE:1-$1\r\n2-$2\r\n3-$3But if I have 2000 lines, the replace should contain several hundred pages. I need another idea.
My only problem is that the Replace expression is too long. I want a shorter replace.
I also try this shorter:
FIND:
^(bebe-55)$
REPLACE:1-\1(?{1}\2)$2But this doesn’t work.
I need a shorter incremental regex, not column editor
Also I
-
add number 1-16, before each line:
1-bebe-55
2-bebe-55
3-bebe-55Notepad++'s existing “Column Editor” can do this already.
I believe the default keycombo is Alt+c (or you can find it on the Edit menu). -
@Alan-Kilborn I need a regex, not column editor, not python.
-
I need a regex, not column editor, not python.
If you have multiple files, it is understandable to exclude column editor, as that’s not practical. But you are choosing to exclude PythonScript: there is a difference. You have access to the plugin, and you know how to use it. So you do not need a regex, you want a regex, which are two different things.
Notepad++'s built-in regex doesn’t do auto-increment, and your previous topic with the edge cases just pointed that out to you (you ended up doing a weird duplicate and edge-case to get a pseudo-‘count’). For this task, you would need to use a plugin – either PythonScript (which you are artificially rejecting), or one of the fancier search plugins that have enabled custom “numbering” syntax – like MultiReplace or Columns++ (or presumably Search++ – I assume @Coises included all the math extras when he ported the searching from Columns++ to Search++)
The Math FAQ already explains how to do counting-like actions in PythonScript and in MultiReplace and in Columns++ (and I assume the Search++ syntax would be the same). There is no reason for us to re-iterate what’s already in the FAQ.
-
Hi, @Neculai-i.-fantanaru and All,
For this purpose, you should study the
Columns++documentation of @coises, below :https://coises.github.io/ColumnsPlusPlus/help.htm#formulas
or with the
MultiReplaceplugin of @thomas-knoefel, from these two links below :https://github.com/daddel80/notepadpp-multireplace/blob/main/FORMULA-SUPPORT.md#lua-reference
https://github.com/daddel80/notepadpp-multireplace/blob/main/FORMULA-SUPPORT.md#exprtk-reference
As you can see, it should be possible with some special regexes to achieve your goal !
Best Regards,
guy038
-
PeterJones said:
I assume the Search++ syntax would be the same
Per the Search++ announcement, it can do the numeric calculations that were first developed for Columns++.
I should update the FAQ soon…
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login