Find lines and remove them

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

Find lines and remove them

Postby Peter » Wed Jan 18, 2006 6:21 pm

Hello

I use UE 10.10c and I want to

a) find lines matching some keywords
b) remove (!) them from my file

To find something, list the lines and copy them to clipboard is not the problem.

The question is: How to remove/delete the lines from file?

Peter
User avatar
Peter
Basic User
Basic User
 
Posts: 33
Joined: Mon Nov 01, 2004 12:00 am
Location: Switzerland

Re: Find lines and remove them

Postby Mofi » Thu Jan 19, 2006 7:42 am

Can be done with a regular expression replace. First determine which style you use for regular expression. Look at Advanced - Configuration - Find - Unix style Regular Expressions. If this option is not enabled, you use regular expressions with UltraEdit style.

To delete some lines with an UltraEdit style regular expression replace use following:

Find What: %*keyword*^p
Replace With:

% ... start of the line
* ... 0 or more occurrences of any character
^p ... line termination (CRLF = carriage return, line feed)

Run Replace All several times until search string not found anymore.

See help of UltraEdit for more details about regular expressions.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4037
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Find lines and remove them

Postby Peter » Thu Jan 19, 2006 11:50 am

Mofi,

that's a way to delete the lines immediately without controling. But I would prefer a solution like this:

- search it
- list it in the window to control the results (that's important)
- remove it - if you want - or cancel it

Peter
User avatar
Peter
Basic User
Basic User
 
Posts: 33
Joined: Mon Nov 01, 2004 12:00 am
Location: Switzerland

Re: Find lines and remove them

Postby Mofi » Thu Jan 19, 2006 12:12 pm

Then do not use "Replace All" but use normal replace with "Start" button. UltraEdit sets the cursor to the first line where your keyword is found and selects the line. Now you have several options like "Find Next", "Replace", ... It's simply a step by step replace with user interaction.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4037
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Find/Replace/Regular Expressions