Delete ALL characters, etc. between two words

Discussion in 'Design and Graphics' started by Jakehotep, Jul 13, 2012.

  1. macrumors newbie

    Joined:
    Jul 13, 2012
    #1
    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.
     
  2. macrumors 6502a

    aarond12

    Joined:
    May 20, 2002
    Location:
    Dallas, TX USA
    #2
    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
     
  3. thread starter macrumors newbie

    Joined:
    Jul 13, 2012
    #3
    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.
     
  4. macrumors 6502

    UTclassof89

    Joined:
    Jun 10, 2008
    #4
    you should be able to use the following GREP query in the find field:

    Sent[[:print:]]*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")
     
  5. thread starter macrumors newbie

    Joined:
    Jul 13, 2012
    #5
    Thank you. I am about to go home and will have to check it tomorrow. I really appreciate your help.
     

Share This Page