0

(I have edited this post for clarity)

I have a terribly formatted text document.. Luckily, though terribly formatted, it's reliably terribly formatted and so regex has saved me days worth of work.

I'm now at the point that I want to provide bookmarks for the table of contents to link to I've managed to replace each section title with

<a name="#insertlinkhere">Assembly</a>
Content under Assembly title.
<a name="#insertlinkhere">Warranty</a>
Content under Warranty title.
<a name="#insertlinkhere">Contact</a>
...

And the like.. each occurrence of insertlinkhere is literally insertlinkhere.

Now what I want to do is replace each `insertlinkhere`\ with an 'a' + iteration-count, so the first three would say

<a name="#a1">Assembly</a>
...
<a name="#a2">Warranty</a>
...
<a name="#a3">Contact</a>
...


<a name="#a48">Assemblage</a>
...
<a name="#a49">Garantie</a>
...

I have googled for this, but I'm not sure my terminology is correct or possibly, notepad++ is not capable of this without a specific addon. Perhaps someone could suggest a program that is.

1

Continued searching while waiting for an answer showed me that TextPad can do incrementalreplace simply enter your Find string (insertlinkhere in my case) and your replace string a\i where \i automatically increments for each replace iteration.

Hope it helps someone else.

0

Yes you can do this in Notepad++ with two steps

step1: Replace (ctrl+h) the word "insertlinkhere" with "a"

<a name="#insertlinkhere">Assembly</a>
<a name="#insertlinkhere">Warranty</a>
<a name="#insertlinkhere">Contact</a>

output:

<a name="#a">Assembly</a>
<a name="#a">Warranty</a>
<a name="#a">Contact</a>

Step2:

Now select the word #a , so that your cursor should be in end of a.

From the Edit menu (ALT+C keyboard shortcut) in your notepad++. Change the radio button to Number to Insert with a starting value of 1 incrementing by 1 (Decimal). Confirm using the OK button. You should end up with this:

<a name="#a1">Assembly</a>
<a name="#a2">Warranty</a>
<a name="#a3">Contact</a>

Hope this helps!

  • Unfortunately, that doesn't work, and it's my fault for not properly explaining that there are gaps between each anchor line.. that column is incremented each row. Thanks for the effort though! – Regular Joe Oct 30 '14 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.