Find and replace

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
alloneword
Posts: 2
Joined: Tue Dec 16, 2003 11:20 am

Find and replace

Post 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.
User avatar
helios
Posts: 711
Joined: Sun Mar 02, 2003 5:52 pm
Location: Helios Software Solutions
Contact:

Post 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.
Helios Software Solutions
alloneword
Posts: 2
Joined: Tue Dec 16, 2003 11:20 am

Post by alloneword »

That worked perfectly... thank-you very much :)
:D
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post 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.
Post Reply