Find last </p> in file

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
steve1040
Posts: 39
Joined: Fri Oct 13, 2006 2:19 am

Find last </p> in file

Post by steve1040 »

I have several webpages I need to insert text into.

How can I find the last </p> in the file and insert text before the last </p>

So find
last instance of </p>

Replace with
****SOMETEXT \n </p>
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I don't think you can do this with TextPad's RegEx, but you might make a macro that goes to the end of the file, do a Search, UP vs. Down, and insert your text.

Or use a macro to locate the last </p> as above, and add a unique character (~ ?) in front of or behind it.

Now you can use RegEx to locate </p>~
Hope this was helpful.............good luck,
Bob
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You can do it in WildEdit (http://www.textpad.com/products/wildedit/):
Find what:
(.*)</p>

Replace with:
$1****SOMETEXT
</p>


[X] Regular expression
[X] Replacement format

Options
[ ] '.' does not match a newline character [i.e., not selected]
An interesting alternative is:
Find what:
</p>(((?!</p>).)*)\z

Replace with:
****SOMETEXT
</p>$1


[X] Regular expression
[X] Replacement format

Options
[ ] '.' does not match a newline character [i.e., not selected]
(The undocumented \z matches the end of the text. See http://www.boost.org/libs/regex/.)
Post Reply