Page 1 of 1

Find and replace

Posted: Tue Dec 16, 2003 11:26 am
by alloneword
Hi, I am trying to use the regular expression to do a fidn and replace, I want to chage:

[1] McGilvary, Half Century, 1912.

to:

[<a name="1">1</a>] McGilvary, Half Century, 1912.

ie. find:

[ NUM ]

replace:

[ <a name="NUM"> NUM </a> ]

(NUM called be 1 - 2 digits)
I read the help file, and came up with something that looked like,
[:digit:]

But I couldn't even get the find to work.

Thanks for any help.

Posted: Tue Dec 16, 2003 12:48 pm
by helios
Please try implementing the following procedure in TextPad:


1. Open the Replace dialog box
2. Type or paste "\[([0-9]+)\]" without the quotes into the "Find what"
section
3. Type or paste "[<a name="\1">\1</a>]" without the quotes into the "Replace with" section
4. Under the heading "Conditions", check "Text and Regular expression"
5. Ensure the curser is at the beginning of the document
6. Click Find Next and Replace, or Replace All

I have used POSIX regular expression syntax, which can be selected from the Editor page of the Preferences dialog box.

Posted: Tue Dec 16, 2003 1:02 pm
by alloneword
That worked perfectly... thank-you very much :)
:D

Posted: Tue Dec 16, 2003 1:48 pm
by MudGuard
One addition:

Some Browsers (don't remember which - might be Netscape 4.x) don't like name attributes that are numbers (although they are allowed in HTML).

Therefore, I advise to add a letter before the number in the name attribute.