Just erase everything before a given string

General questions about using TextPad

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

Post Reply
Rosseiro
Posts: 14
Joined: Tue Mar 22, 2011 1:33 am

Just erase everything before a given string

Post by Rosseiro »

Hi,
I think this is so easy I'm embarassed to ask, but curiously I can't figure how to take this:

Code: Select all







}
.auto-style1 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 1em;
}



<h2>segunda-feira, 10 de outubro de 2011</h2>


...and remove everthing before the first <h2> string. Doesn't matter what its contents are, but it must take into consideration that I want to wipe the blank lines there too.

Thanks for your help in advance.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Code: Select all

Control-Home       (positions cursor at beginning of file)
Search for <h2>    (selects first <h2>)
Close Search box 
Cursor left        (unselects first <h2> and positions cursor to left of <h2>)
Control-Shift-Home (selects everything from cursor positon (which is left of first <h2>) to start of file - and puts cursor to start of file)
Delete             (removes selection, i.e. everything up to first <h2>)
If you need this more often, record it as a macro
Rosseiro
Posts: 14
Joined: Tue Mar 22, 2011 1:33 am

Post by Rosseiro »

I thought about this workaround, thanks! But in that case, there is no RegEx applicable? Thanks anyway MudGuard.

Edit: actually, I remembered the problem about having to do this via macro: What if I have 167 html files in that situation? I would have to open one by one and execute the macro. With a find-replace using RegEx, then I would take one tenth of that time, right?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

This has been discussed here many times before. Unfortunately, TextPad's regex recogniser is incapable of matching an arbitrary number of newlines. So your problem cannot be solved in TextPad with a single regular expression replacement.

Other tools, such as WidlEdit (http://www.textpad.com/products/wildedit/) use more modern and powerful regex engines that do not suffer from this restriction.
Rosseiro
Posts: 14
Joined: Tue Mar 22, 2011 1:33 am

Post by Rosseiro »

Thanks for the tip.
Post Reply