Go Back   MacRumors Forums > Special Interests > Visual Media > Design and Graphics

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 13, 2012, 07:25 AM   #1
Jakehotep
macrumors newbie
 
Join Date: Jul 2012
Delete ALL characters, etc. between two words

I'm a total newbie at Grep.

I have a problem that makes me want to rip out what little hair I have left.

I received a bunch of blogs and consolidated them into one InDesign (CS3) file, and now I'm trying to format them for easier reading in one file. However, there are some relatively common elements to each one that I'd like to delete using Grep.

I'd like to remove EVERY character, space, digit, space, and whatnot, between the words "Sent" and "PDT". Note that there could be a more than a hundred characters between those two elements. Please help. It would make this project so much easier, and would help with future problems of this type.
Jakehotep is offline   0 Reply With Quote
Old Jul 13, 2012, 09:01 AM   #2
aarond12
macrumors 6502a
 
aarond12's Avatar
 
Join Date: May 2002
Location: Dallas, TX USA
Why not use "sed"? Grep probably isn't the best choice here.

Code:
sed 's/Sent .* PDT/Sent PDT/' < test.txt
My test.txt file contains:
Email Sent asdflkjasdlfkjasdlfk sdfkjsd kjsdff PDT

Putting it through that sed line outputs:
Email Sent PDT
__________________
Voted "Most likely to start his own cult" by my high school class.
aarond12 is offline   1 Reply With Quote
Old Jul 13, 2012, 09:15 AM   #3
Jakehotep
Thread Starter
macrumors newbie
 
Join Date: Jul 2012
Like I said, I'm a noob. I only first heard of sed yesterday while searching for the same solution, and have no idea how to access it.

I'm more of a DTP guy (got my start with PageMaker) and have been noodling around with scripting with Automator and Applescript for the past year or so. If I could set this up in InDesign using the GREP command, that would be great, but if I'm stuck using sed instead (so to speak) that would be fine. I just don't know how to use it and could use some more basic instruction. For instance, is it used through Terminal? Thanks for your response, by the way.
Jakehotep is offline   0 Reply With Quote
Old Jul 13, 2012, 12:57 PM   #4
UTclassof89
macrumors 6502
 
Join Date: Jun 2008
you should be able to use the following GREP query in the find field:

Sent[[rint:]]*PDT

and

Sent PDT

in the Change To field
(ignore the emoticon MR placed in there: that should be two opening brackets, a colon, and then the word "print")
__________________
Flash will be around a lot longer than Steve Jobs will.
UTclassof89 is offline   1 Reply With Quote
Old Jul 13, 2012, 01:28 PM   #5
Jakehotep
Thread Starter
macrumors newbie
 
Join Date: Jul 2012
Thank you. I am about to go home and will have to check it tomorrow. I really appreciate your help.
Jakehotep is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Design and Graphics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Characters delete when I paste, please help snerkler Mac Basics and Help 2 Aug 19, 2013 06:19 AM
Characters zaze01 Mac OS X 10.7 Lion 2 Jan 31, 2013 09:29 PM
Road Words - (Type words while dodging traffic!) [FREE] jswiney iPhone and iPod touch Apps 0 Dec 12, 2012 04:15 PM
Wouldn't it be great if you could hit shift then backspace to delete whole words? TH55 iPhone 4 Sep 29, 2012 10:16 PM

Forum Jump

All times are GMT -5. The time now is 02:25 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC