Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 22nd, 2012, 10:45 AM
terrypin terrypin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 1 terrypin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 15 sec
Reputation Power: 0
Deleting many lines of text between specified characters?

Hi,
First post here and I'm hoping one of the experts can help please. I have a text file that looks like this:

--- Start paste ---

[BlackfordLane.jpg]
File name = BlackfordLane.jpg
Directory = C:\Docs\My Videos\PROJECTS\Thames Path Walk Projects\TP03 Project\Geograph Photos\GeoDay2\
Compression = JPEG, quality: 87, subsampling OFF
Resolution = 96 x 96 DPI
File date/time = 19/01/2012 / 15:01:23

- IPTC -
Object Name - s bridge over the River Thames is not a footbridge but carries pipes.

- COMMENT -
Thames Path on Blackford Lane heading towards Blackford Farm, east of Castle Eaton.

[Castle Eaton Church.jpg]
File name = Castle Eaton Church.jpg
Directory = C:\Docs\My Videos\PROJECTS\Thames Path Walk Projects\TP03 Project\Geograph Photos\GeoDay2\
Compression = JPEG, quality: 87, subsampling OFF
Resolution = 72 x 72 DPI
File date/time = 19/01/2012 / 14:03:55

- EXIF -
Make - FUJIFILM
Model - FinePix2600Zoom
Orientation - Top left
XResolution - 72
YResolution - 72
ResolutionUnit - Inch

- COMMENT -
Castle Eaton Church

[CastleEaton-2.jpg]
File name = CastleEaton-2.jpg
Directory = C:\Docs\My Videos\PROJECTS\Thames Path Walk Projects\TP03 Project\Geograph Photos\GeoDay2\
Compression = JPEG, quality: 75
Resolution = 0 x 0 DPI
File date/time = 18/01/2012 / 15:40:05

- COMMENT -
The Red Lion, Castle Eaton
A warm welcoming pub on a cold winter's day, with the River Thames running at the bottom of the garden.

This is what I want to get as a result:

BlackfordLane.jpg
Thames Path on Blackford Lane heading towards Blackford Farm, east of Castle Eaton.

Castle Eaton Church.jpg
Castle Eaton Church

CastleEaton-2.jpg
The Red Lion, Castle Eaton
A warm welcoming pub on a cold winter's day, with the River Thames running at the bottom of the garden.

My first line of attack is to try for a Regex expression that will Find everything (for example) between the ']' of '[BlackfordLane.jpg]' and the '-' of '- COMMENT -'? That would leave only a little tidying up, I think.

But so far that's eluded me after a couple of hours. The best I could come up with was the following to delete all lines from File name... to File date/time (with the Replace box empty):

File name = .*\nDirectory = .*\nCompression = .*\nResolution = .*\nImage dimensions = .*\nPrint size = .*\nColor depth = .*\nNumber of unique colors = .*\nDisk size = .*\nCurrent memory size = .*\nFile date/time = .*\n

But that's only part of the task and seems very inelegant.

Any suggestions please?

--
Terry, East Grinstead, UK

Reply With Quote
  #2  
Old January 22nd, 2012, 09:08 PM
ragax's Avatar
ragax ragax is offline
Turn left at the third duck
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Location: Nelson, NZ
Posts: 93 ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 24 m 37 sec
Reputation Power: 92
Mmm...
I think this is a cross-post.

As I suggested elsewhere in more detail:
Search: (?sm)\[([^]]+.jpg)\].*?- COMMENT -(\r\n[^[]*)
Replace: \1\2

Reply With Quote
  #3  
Old January 23rd, 2012, 12:40 AM
requinix's Avatar
requinix requinix is offline
Still alive
Dev Shed God 16th Plane (12500 - 12999 posts)
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,877 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 5 Days 7 h 59 m 26 sec
Reputation Power: 8977
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Deleting many lines of text between specified characters?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap