RE on multiple lines using TextPad 5.0

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
lugger_house
Posts: 3
Joined: Mon Aug 17, 2009 6:39 pm

RE on multiple lines using TextPad 5.0

Post by lugger_house »

Hello Guys,

I have a XML file login errors with this architechture:

Code: Select all

<error>
    <many other tags />
    <description><description>
</error>
And I would like to remove all the errors with the description containing a sql query (select...... where)

My Regular expression works when everything is on one line but I cannot figure out how to set it up to accomodate the multiple "\n"

Any suggestions ??

thanks
Lugger_House
Montreal, QC
Canada
paleolith
Posts: 46
Joined: Sun Jun 26, 2005 6:25 pm
Contact:

Post by paleolith »

TextPad cannot handle a variable number of newlines in an RE. If there's a limit to the number of newlines, you could do several replacements -- first with no newlines, then with one newline, then two, etc to the max.

Or you could replace all /n by something that's not in the file, for example <newline>. Then do the replacement, and finally replace <newline> or whatever you used back to \n.

Edward
lugger_house
Posts: 3
Joined: Mon Aug 17, 2009 6:39 pm

Post by lugger_house »

thanks for your answer, I will try that :-)
Lugger_House
Montreal, QC
Canada
lugger_house
Posts: 3
Joined: Mon Aug 17, 2009 6:39 pm

Post by lugger_house »

Here's the final steps for myself to remember or, who knows, maybe for you that reads this post ;-)

Code: Select all

1) replace \n by <newline> (as an regular expression, replace all)
2) replace </error><newline> by </error>\n (so we will have one error per line)
3) Find ^<error>.*What ever my error description was.*</error>$(as an regular expression, mark all)
4) Edit-Cut Other-Bookmarked lines
5) replace <newline> by \n.
This seems a little bit teadious but when the logfiles gets up to few hundred Mb and 75% are useless entries the manipulation worth the few minutes it take ;-)
Lugger_House
Montreal, QC
Canada
paleolith
Posts: 46
Joined: Sun Jun 26, 2005 6:25 pm
Contact:

Post by paleolith »

You should be able to make a macro out of this sequence. TP macros are a bit hard to use because you have to get them right in one shot -- no editing -- but if you're doing this repeatedly, it will be worth the effort.

Edward
Post Reply