Indesign GREP HELP!

Discussion in 'Design and Graphics' started by Simon8888, Feb 14, 2016.

  1. Simon8888 macrumors newbie

    Joined:
    Feb 14, 2016
    #1
    Hi, does any one know a good grep formula in Indesign for removing paragraph breaks before lowercase letters, and replacing them with a space?

    When I try it finds the lowercase letter, but highlights it also, meaning that the lowercase letter will also be replaced along with the paragraph break. Anyone know how to get it to just find the paragraph break?

    Thanks
    Simon
     
  2. telecomm macrumors 65816

    telecomm

    Joined:
    Nov 30, 2003
    Location:
    Rome
    #2
    I'm not familiar with InDesign, and only a rookie with GREP, but I can tell you how this would work in a text editor like TextWrangler (which may help if you can do something similar in InDesign).

    The rough idea is to search for "paragraph break followed by lowercase letter", then replace with "space followed by the same lowercase letter."

    In TextWrangler I'd search for "\r([a-z])" (a line break followed by a single lowercase letter) then replace with " \1". The \1 is a reference to the expression found in parentheses, so in this case, it's whichever single lowercase letter was found right after a line break. This lets you essentially re-insert that letter where it was, but replace whatever was before it.
     
  3. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #3
    You can use a positive lookahead in InDesign like so:

    \r(?=[a-z])

    Basically it means a return followed by any character a-z, but the match does not *contain* the a-z character... if that makes any sense.

    Note that if you have to consider any languages with lowercase characters other than a-z (e.g. Greek, Russian etc) then you'll need to to a little tweaking.
     

    Attached Files:

  4. dwig macrumors 6502

    Joined:
    Jan 4, 2015
    Location:
    Key West FL
    #4
    ... and you possibly need to deal with numerals and mid-sentence symbols (e.g. $, &, (, ", en dash, em dash, ...) following the spurious line break. You also won't be able to distinguish between mid-sentence capitals.

    It might be better to search for line breaks not preceded by periods. I'm not a code meister so perhaps someone else can post the code to do this.
     
  5. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #5
    Just for the sake of completeness: InDesign has some metacharacters for situations such as the ones we've touched on (e.g. non latin languages). You could use something like:

    Code:
    \r(?=\l)
    ...to match lowercase characters which I expect will include non-latin characters. Exactly what InDesign considers lower case, I don't know so I guess you'd need to do some experimenting and testing. There are some fun situations in languages such as Georgian!

    There's a full list of meta characters for InDesign here:


    http://www.jetsetcom.net/images/downloads/list_of_grep_symbols.pdf
     
  6. Simon8888 thread starter macrumors newbie

    Joined:
    Feb 14, 2016
    #6
    Thank you, I think the GREPS are similar so I can try this. Thanks for your time
    --- Post Merged, Feb 17, 2016 ---
    Ah clever, thank you for this advice!
    --- Post Merged, Feb 17, 2016 ---
    Wow that's brilliant, your formula worked perfectly, you've saved me 2 days of deleting paragraph returns!
     

Share This Page