Page 1 of 1

Just erase everything before a given string

Posted: Thu Nov 24, 2011 10:54 pm
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.

Posted: Thu Nov 24, 2011 11:12 pm
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

Posted: Fri Nov 25, 2011 1:40 am
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?

Posted: Fri Nov 25, 2011 8:14 am
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.

Posted: Fri Nov 25, 2011 4:32 pm
by Rosseiro
Thanks for the tip.