Page 1 of 1
RE on multiple lines using TextPad 5.0
Posted: Mon Aug 17, 2009 6:48 pm
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
Posted: Mon Aug 24, 2009 8:25 pm
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
Posted: Thu Aug 27, 2009 2:54 pm
by lugger_house
thanks for your answer, I will try that

Posted: Thu Aug 27, 2009 3:46 pm
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

Posted: Thu Aug 27, 2009 5:21 pm
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