Jeff Scism wrote: [ . . ] ... regex tagged match comes to mind. but then to do so may requisite to use the replace command instead of insert command

Message 3 of 12
, Aug 1, 2004

0 Attachment

Jeff Scism wrote:
[ . . ]

> The line I need to change is formatted as follows:
>
> (Son of No. 1) through (Son of No. 1646)
>
> The goal is to via directory replacement clip, to change each NUMBER
> that follows "No. " into a hyperlink
> This clip works for that:
> ^!INSERT <A HREF="^&.htm">^&</A>
>
>
> How do I get the program to find the "No. " in each document and select
> the word AFTER it for the Insert conversion to a link?

regex tagged match comes to mind. but then to do so may requisite to
use the replace command instead of insert command

(find-tagged-match-regex then the next code line is replace and/or may
just only need the right replace-tagged-match-regex as a one liner
instead of two lines) a.k.a. U may need two lines of code *OR* you may
need one line of code.
--

idea of tagged match is to change something that is next or adjacent to
something else

potentially a solution. as to the best or whether overcomplicated or
not, well I'll leave that for further discussion if seen and needed by
other list memebers.

might search the yah archives for regex and/or tagged match

two help files in Notetab. regex is NOT in the clip help of those two

--
Alan.

Jeff Scism

^!set %prev%=^$strcopyright( 000^$calc(^$getname(^##)$-1)$ ;3)$.htm ^!insert nnn This would insert the following to file 007.htm

> few of them suffixed with the lower case a,b,c, etc.
>
> The line I need to change is formatted as follows:
>
> (Son of No. 1) through (Son of No. 1646)
>
> The goal is to via directory replacement clip, to change each

NUMBER

> that follows "No. " into a hyperlink
> This clip works for that:
> ^!INSERT <A HREF="^&.htm">^&</A>
>
>
> How do I get the program to find the "No. " in each document and

select

> the word AFTER it for the Insert conversion to a link?
>
> I am already using the DIRSTUFF clips to do the sequential changes

Well if you really want to be gutsy and you are using NoteTab Pro or
Std, you might be able to do this without a clip. By using the built
in Search/Search Disk tool. I use Search Disk a lot, it saves me
countless hours in situations like this.

Before trying this however, you'd better do a LOT of testing of this
on dummy files. This also assumes you will want to wrap ALL
occurrences of numbers contained within the following text:

Son of No. ###

where ### represents any number of or sequences of digits.

with HTML anchor tags. And to do this in all the HTML documents
within a folder.

Now if that doesn't scare you away, here's how you can do it with
Search Disk. First press CTRL+D to bring up the Search Disk Dialog
box. Click on the REPLACE tab and make sure the "Reg Expr." box is
NOT checked. Then click the CANCEL button to close Search Disk.
Next in a new unsaved document, type the following two lines exactly
as they are below:

Son of No\. {[0-9]+}

<a href="\1.htm">\1</a>

Then select the bottom line (<a href="\1.htm">\1</a>) and copy it to
the Windows clipboard. Next select the top line (Son of No\. {[0-9]
+}) and press CTRL+D to bring up the Search Disk dialog box again.
With that open click the replace tab and you should see your selected
text in the "Find What" box. Click in the "Replace With" box and
paste in <a href="\1.htm">\1</a> that you had previously copied to
the Windows clipboard by pressing CTRL+V.

Next (still in Search Disk) in the "Search Directory Options"
section, browse to the folder that contains the files you want to
process. After you have selected that folder and pressed OK, make
sure the "Search Directory Options" path looks something like this:

C:\my tests\temp\*.htm*

where the path ends with *.htm*

Ok, you're just about ready to do this. The last steps are to
optionally check the "Backup" box to make backups of all the files
that will be changed, and to uncheck the "Subdirectories" box, and
then finally, to check the "Reg Expr." box.

Take a deep breath then press the START button and sit back and watch
what happens. If you did everything correctly after a minute or two
(depending upon the speed of your computer) you should see a NoteTab
box pop up telling you how many changes were made to how many files.

As I said though, I'd do a LOT of testing with this on dummy files
before trying it on the real ones.

Good luck,

John

PS Alternatly, you can use a clip to find the number to be replaced
by searching for "
Son of No\. {[0-9]+}" as long as you have the RegExp option checked.

> The line I need to change is formatted as follows:
>
> (Son of No. 1) through (Son of No. 1646)
>
> [...]
>
> How do I get the program to find the "No. " in each document and select
> the word AFTER it for the Insert conversion to a link?
>
> [...]
>
> Select directory (this I can do)
> Find in all Documents "No. " (this I can do)
> SELECT the word AFTER "No. " to the clipboard
> ^!INSERT <A HREF="^&.htm">^&</A> (this I can do)
> Close and save silently
> loop to Next document in the directory (this I can do)

Hi Jeff,

The following regexp works on your example text. It assumes a single
space between "No." and "<one or more digits>". The "^!Jump SELECT_END"
may not be necessary if there is only a single instance to be changed in
each document.

It's under the --- Format Links --- section. If you get "Out of Memory"
errors, you'll need to do it on smaller amounts of files at a time and
possibly restart NoteTab each set. Definitely make backups!

>Each of 1647 HTML pages needs to link to the proper "parent" document.
>
>The pages are in the SAME directory, and are numbered 01-1647.htm with a
>few of them suffixed with the lower case a,b,c, etc.
>
>The line I need to change is formatted as follows:
>
>(Son of No. 1) through (Son of No. 1646)
>
>The goal is to via directory replacement clip, to change each NUMBER
>that follows "No. " into a hyperlink
>This clip works for that:
>^!INSERT <A HREF="^&.htm">^&</A>
>
>
>How do I get the program to find the "No. " in each document and select
>the word AFTER it for the Insert conversion to a link?
>
>I am already using the DIRSTUFF clips to do the sequential changes on
>some other portions of webpages, but I am looking for the process of
>selecting the next word (which is a sequentially numbered reference),
>for the Looped Clip running.
>
>FLOW CHART:
>
>Select directory (this I can do)
>Find in all Documents "No. " (this I can do)
>SELECT the word AFTER "No. " to the clipboard
>^!INSERT <A HREF="^&.htm">^&</A> (this I can do)
>Close and save silently
>loop to Next document in the directory (this I can do)

It's under the --- Format Links --- section. If you get "Out of Memory"
errors, you'll need to do it on smaller amounts of files at a time and
possibly restart NoteTab each set. Definitely make backups!

>Each of 1647 HTML pages needs to link to the proper "parent" document.
>
>The pages are in the SAME directory, and are numbered 01-1647.htm with a
>few of them suffixed with the lower case a,b,c, etc.
>
>The line I need to change is formatted as follows:
>
>(Son of No. 1) through (Son of No. 1646)
>
>The goal is to via directory replacement clip, to change each NUMBER
>that follows "No. " into a hyperlink
>This clip works for that:
>^!INSERT <A HREF="^&.htm">^&</A>
>
>
>How do I get the program to find the "No. " in each document and select
>the word AFTER it for the Insert conversion to a link?
>
>I am already using the DIRSTUFF clips to do the sequential changes on
>some other portions of webpages, but I am looking for the process of
>selecting the next word (which is a sequentially numbered reference),
>for the Looped Clip running.
>
>FLOW CHART:
>
>Select directory (this I can do)
>Find in all Documents "No. " (this I can do)
>SELECT the word AFTER "No. " to the clipboard
>^!INSERT <A HREF="^&.htm">^&</A> (this I can do)
>Close and save silently
>loop to Next document in the directory (this I can do)