Page 1 of 1

Delete x lines, then stop

Posted: Tue Mar 17, 2015 7:07 am
by rossnixon
I have text files which I want to remove the first 9 lines from.
I have not been able to work out the syntax. Using Windows, so need to remove the CRLF characters also.

Alternative solution possible, as line 10 always begins with the word "Region" (without quotes),
so a solution which removes everything prior to this text would also be suitable.

Thanks for any answers!

Re: Delete x lines, then stop

Posted: Wed Mar 18, 2015 12:01 pm
by DigitalVolcano
You can try

Regex:

Code: Select all

.*?(region)
Replace:
$1

With 'dot maches newline' checked.

This should work if you don't have later lines with 'region' in the file, otherwise you may lose more data. Always test and back up first!

Re: Delete x lines, then stop

Posted: Thu Jul 14, 2016 11:48 am
by me_suzy
see https://forum.sublimetext.com/t/regex-m ... mpty/20850

This will delete the first 10 lines.

(\s*^(\h*\S.*)){10}

Re: Delete x lines, then stop

Posted: Thu Jul 14, 2016 11:51 am
by rossnixon
Thanks Suzy.
In the end I went with a compiled AutoIt script to process all the files in a folder.

Re: Delete x lines, then stop

Posted: Thu Jul 14, 2016 12:30 pm
by me_suzy
it is good this Autoit software?

Re: Delete x lines, then stop

Posted: Thu Jul 14, 2016 9:49 pm
by rossnixon
It is good for me. I use it to automate several tasks in my job. It isn't a full programming language though.

AutoIt is typically used to produce utility software for Windows and to automate routine tasks, such as systems management, monitoring, maintenance, or software installation. It is also used to simulate user interaction, whereby an application is "driven" (via automated form entry, keypresses, mouse clicks, and so on).
https://en.wikipedia.org/wiki/AutoIt