Deleting last line in files

General discussions about Advanced Find and Replace
Post Reply
frankm
Posts: 3
Joined: Fri Mar 02, 2007 1:10 am

Deleting last line in files

Post by frankm » Sun Aug 19, 2007 1:37 am

I'm sure this is easy but I can't figure out how to do it.

I want to use AFR to delete the last line of a few thousand text files but I don't know what regular expression to use to select the last line - the last lines don't necessarily end with line breaks.

Thanks

Abacre
Site Admin
Posts: 1201
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Re: Deleting last line in files

Post by Abacre » Sun Aug 19, 2007 7:18 pm

Go to main menu - Action - Options - Batch Replace
check "Modifier S"
check "Modifier G"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
\A(.*)\r\n.*\r?\n?\Z

Replace with:
$1

That's all I verified it works perfectly.

Note: in this example we use line breaks used in Windows (\r\n)
Otherwise you should use search for: \A(.*)\n.*\n?\Z
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

frankm
Posts: 3
Joined: Fri Mar 02, 2007 1:10 am

Re: Deleting last line in files

Post by frankm » Mon Aug 20, 2007 12:28 am

Thank you Roman - that works great. :D

digitalmonkeyman
Posts: 4
Joined: Sun Sep 16, 2007 7:35 am

Re: Deleting last line in files

Post by digitalmonkeyman » Sat Sep 22, 2007 6:14 am

solution received


Thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests