Delete x lines, then stop

A place to try and solve your RegEx problems.
Post Reply
rossnixon
Posts: 3
Joined: Tue Mar 17, 2015 7:00 am

Delete x lines, then stop

Post by rossnixon » Tue Mar 17, 2015 7:07 am

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!
User avatar
DigitalVolcano
Site Admin
Posts: 1074
Joined: Thu Jun 09, 2011 10:04 am

Re: Delete x lines, then stop

Post by DigitalVolcano » Wed Mar 18, 2015 12:01 pm

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!
me_suzy
Posts: 12
Joined: Thu Jul 14, 2016 11:31 am

Re: Delete x lines, then stop

Post by me_suzy » Thu Jul 14, 2016 11:48 am

see https://forum.sublimetext.com/t/regex-m ... mpty/20850

This will delete the first 10 lines.

(\s*^(\h*\S.*)){10}
rossnixon
Posts: 3
Joined: Tue Mar 17, 2015 7:00 am

Re: Delete x lines, then stop

Post by rossnixon » Thu Jul 14, 2016 11:51 am

Thanks Suzy.
In the end I went with a compiled AutoIt script to process all the files in a folder.
me_suzy
Posts: 12
Joined: Thu Jul 14, 2016 11:31 am

Re: Delete x lines, then stop

Post by me_suzy » Thu Jul 14, 2016 12:30 pm

it is good this Autoit software?
rossnixon
Posts: 3
Joined: Tue Mar 17, 2015 7:00 am

Re: Delete x lines, then stop

Post by rossnixon » Thu Jul 14, 2016 9:49 pm

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
Post Reply