Delete x lines, then stop

A place to try and solve your RegEx problems.

Delete x lines, then stop

Postby 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!
rossnixon
 
Posts: 3
Joined: Tue Mar 17, 2015 7:00 am

Re: Delete x lines, then stop

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

Re: Delete x lines, then stop

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

Re: Delete x lines, then stop

Postby 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.
rossnixon
 
Posts: 3
Joined: Tue Mar 17, 2015 7:00 am

Re: Delete x lines, then stop

Postby me_suzy » Thu Jul 14, 2016 12:30 pm

it is good this Autoit software?
me_suzy
 
Posts: 10
Joined: Thu Jul 14, 2016 11:31 am

Re: Delete x lines, then stop

Postby 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
rossnixon
 
Posts: 3
Joined: Tue Mar 17, 2015 7:00 am


Who is online

Users browsing this forum: No registered users and 1 guest