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 July 12th, 2012, 02:35 PM
misery misery is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 1 misery User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m
Reputation Power: 0
Edit a text file -- Please help!

Hi,

I have a very large text file on my desktop, with about 2500 lines.

Each line is quite short, each containing either a song file or movie file, here's a sample list of them:

Signs 2002 TLKDA9ALKADNCLA0
Sleuth.1972.882.27fps.562kbs.v7vbr.wunseedee
Snabba.Cash.2010.SWEDiSH.VID.WpLA

I need a code that will identify 4 numbers in a row (a date) and remove all characters after that. I want the red text to be removed... This must be repeated for each line (a loop?)

The second function I need done is to replace underscores "_" with a space, and also I'd like to replace periods "." with a space. I would like the altered text file to then be written back to my desktop.

So ultimately, the 3 file names above should end up like this in a new text file:

Signs 2002
Sleuth 1972
Snabba Cash 2010

I'm using TextPad, but have NO idea what type of code to use... or what it should look like. I was only told to use "Regular Expressions"...

Please help, thanks a lot!!

Reply With Quote
  #2  
Old July 13th, 2012, 02:51 AM
abareplace abareplace is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Posts: 29 abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level)abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level)abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level)abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level)abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level)abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level)abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level)abareplace User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 8 h 25 m 9 sec
Reputation Power: 0
1) Use the following code:

Code:
Search for: (?<=\d{4}).*
Replace with: (empty string)


TextPad uses POSIX regular expressions, so this probably will not work with it. You can try another editor.

2) For replacing underscores and periods, you can use the usual search and replace (without regular expressions).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Edit a text file -- Please help!

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