Page 1 of 1

Searching Multiple Lines

Posted: Thu Mar 07, 2002 7:37 am
by Khek
Any suggestion on writing the regular expression would be greatly appreciated. I am trying write an expression that will search an html tag on multiple lines. For example:
<td style="x-cell-content-align: TOP; width: 17%;"
valign=top
width=17%>

I'm am trying to write the expression that searches <td .*... > Because this example stretches several lines, I'm not sure how to complete this. Any thoughts? Thank you.

Re: Searching Multiple Lines

Posted: Thu Mar 07, 2002 11:37 am
by Andreas
Unfortunately, textpad does not support operators * and + on any partial expression containing \n

One way of doing it is replacing \n by a combination of characters that is not found in the text, e.g. @@@
Then do your Regex search/replace
Then replace @@@ (or whatever you chose in step one) by \n

Re: Searching Multiple Lines

Posted: Thu Mar 07, 2002 2:50 pm
by Roy Beatty
> One way of doing it is replacing \n by a combination of characters

This works fine -- but be careful not to perform this on too many lines at the same time. I once tried this on a vary large file, ~50mb, I think . TextPad then had to work on oneextremely long line, and the operation took tens of minutes. Even undo took a long time. Scripting was the more appropriate tool in that case.

Re: Searching Multiple Lines

Posted: Fri Mar 08, 2002 9:55 am
by Carlyle Sutphen
Scripting?

Re: Searching Multiple Lines

Posted: Fri Mar 08, 2002 11:15 pm
by Roy Beatty
Sorry -- Python, Perl or some other programming language built with text manipulation in mind -- these tools let me edit my instructions and try again. They're called "scripting languiages" because all of the instructions are entered as text, are editable and do not require a GUI to build or run them.

With TextPad keystroke macros, you have to key in just so, or you have to key it in all over again.

You know, like punch cards.

www.python.org<br>
www.perl.org

Re: Searching Multiple Lines

Posted: Mon Mar 11, 2002 8:26 am
by Carlyle Sutphen
I usually use sed. I'll use awk if it really needs complex procedural operations. Then perl is the chosen tool when text mangling has to be combined with something like interprocess communication or database I/O.

I'm not really old school, only been working with unix for 20yrs. Now company policy put an NT desktop in front of me so I can integrate my workflow with the rest of the company.

TextPad is a godssend for me. It let's me write code without all the GUI schnick-schnack.

I do miss the MS Programmer's Workbench that was delivered with the C compiler back in the old Win3.1 days. Anybody remember that? You could program C modules for it to do tasks that it's scripting capabilities fell short of. But in many ways TextPad reminds me of it.

Re: Searching Multiple Lines

Posted: Tue Mar 12, 2002 4:49 pm
by Khek
Thanks for all the input. I also found a solution as well:

<td.*\n.*\n.*> - this will allow you to search tags starting with "td" and any code inbetween. The only limitation is that it searches for tags that spans on 3 lines.