regular expression help

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
juanpgadea
Posts: 10
Joined: Mon Jun 12, 2006 12:11 pm

regular expression help

Post by juanpgadea »

Hi, i need to replace

...los jdu<sup>1</sup>
...jhs<sup>2</sup>
.
.
.
...<sup>...jgas<sup>525</sup>

with
...los jdu<FN>1</FN>
...jhs<FN>2</FN>
.
.
.
...<sup>...jgas<FN>525</FN>


I have <sup> and </sup> that i dont have to replace only replace the ones with the format <sup>number</sup>

Thanks
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

You need to perform the following search and replace:

Find:
<sup>([0-9]*)</sup>
Replace:
<FN>\1</FN>
With regular expression enabled and using POSIX regular expression syntax.

The round brackets allow you to refer to the found number between the angle brackets when creating the replacement expression.
juanpgadea
Posts: 10
Joined: Mon Jun 12, 2006 12:11 pm

Post by juanpgadea »

Tnaks, i works, but in some cases i have an space after the number

<sup>12 </sup>

how can i solve these problem

Thanks
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

You need to modify the search expression to include a space repeated zero or more times.

find
<sup>([0-9]*) *</sup>
Please note there is a space after the ).

Using the previous replacement expression this will strip out any spaces after numbers i.e. <sup>2 </sup> will become <FN>2</FN>. If you want to keep the spaces then move the closing round bracket from after the first * to after the second *.

Hope this helps.
Post Reply