how to remove multiple lines that starts/contains...

Find, replace, find in files, replace in files, regular expressions

how to remove multiple lines that starts/contains...

Postby lxz20 » Thu May 26, 2005 8:54 pm

Hello. i'm new to UE.
i'm converting html file to a txt file daily.
so i was looking for tool that can do it automatically.
let's say my source looks like this.

<LINE TO REMOVE #1>
5342 : EXAMPLE #1
<tr><remove this line>
<LINE TO REMOVE #3>
6242 : EXAMPLE #2
<tr><remove this line>
<LINE TO REMOVE #4>
6424 : EXAMPLE #3
<tr><remove this line>


i want to remove all of above lines.

Rule #1 : remove lines that contains LINE TO REMOVE
Rule #2 : remove lines that starts with numeric characters
Rule #3 : remove lines that starts with <tr>

is it possible?
Thanks in advance
User avatar
lxz20
Newbie
 
Posts: 4
Joined: Sun Jul 31, 2005 11:00 pm

Re: how to remove multiple lines that starts/contains...

Postby MrBillG » Thu May 26, 2005 10:41 pm

Hi r4bb1t

Right off the top of my head there's a macro called
HTML Strip Macros
http://www.ultraedit.com/files/macros/htmstrip.zip

Maybe someone else has a better idea!
User avatar
MrBillG
Advanced User
Advanced User
 
Posts: 65
Joined: Sat Aug 07, 2004 11:00 pm

Re: how to remove multiple lines that starts/contains...

Postby lxz20 » Fri May 27, 2005 6:26 am

Hello MrBillG.
Thanks for reply.

i've tried that macro and it works a bit different with my needs
i think this macro deletes everything between < >
i need file locations of 'a href' links. it's not for me. :(
but thank for your kindness MrBillG.

any other comments would be appreciate.
Thanks in advance.
User avatar
lxz20
Newbie
 
Posts: 4
Joined: Sun Jul 31, 2005 11:00 pm

Re: how to remove multiple lines that starts/contains...

Postby mrainey56 » Fri May 27, 2005 9:10 am

Should be easy. Try this macro.

InsertMode
ColumnModeOff
HexOff
UnixReOn
Top
Find RegExp "^.*LINE TO REMOVE.*\p"
Replace All ""
Top
Find RegExp "^[0-9].*\p"
Replace All ""
Top
Find RegExp "^<tr>.*\p"
Replace All ""
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: how to remove multiple lines that starts/contains...

Postby lxz20 » Fri May 27, 2005 11:21 am

Thanks for answer mrainey56.
you were very helpful :)
it's working as what i requested.
but can i ask one more thing?
after your macro, i got this result.

| http://filelocation/is/here1.asp random text
| http://filelocation/is/here2.asp r a n d o m text 2
| http://filelocation/is/here3.asp ra nd om te xt 3

I want to reformat these into..

random text | http://filelocation/is/here1.asp
r a n d o m text 2 | http://filelocation/is/here2.asp
ra nd om te xt 3 | http://filelocation/is/here3.asp


i have tried ^(|.*..asp) ^([a-z]) then replace ^2 ^1 but it's not working atm.
first string grouped between | and .asp
second string is random texts.(including numerics)
can you point me what i'm wrong?
Thank you very much
User avatar
lxz20
Newbie
 
Posts: 4
Joined: Sun Jul 31, 2005 11:00 pm

Re: how to remove multiple lines that starts/contains...

Postby mrainey56 » Fri May 27, 2005 12:26 pm

Try adding this to the end of the first macro:

Top
Find RegExp "^([|].*[.]asp)( )(.*)$"
Replace All "\3 \1"


I didn't work with your search/replace strings, but did notice that you were using Ultra Edit syntax for the tagged expressions, while I was in Unix mode.

If you're going to switch modes inside a macro, make sure you first stick the appropriate line in your macro:

UnixReOn

or

UnixReOff
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: how to remove multiple lines that starts/contains...

Postby lxz20 » Fri May 27, 2005 8:28 pm

ahh
i didn't realized that, mrainey56.
however now it's working.
you saved a lot of my time hehe

Thank you very much.
i got to learn more about UE.
very useful :)
User avatar
lxz20
Newbie
 
Posts: 4
Joined: Sun Jul 31, 2005 11:00 pm


Return to Find/Replace/Regular Expressions