Find and Replace GREP, Keep Some Wildcards

Learn / Forums / General InDesign Topics / Find and Replace GREP, Keep Some Wildcards

Viewing 5 reply threads
  • Author
    Posts
    • #74448

      When a client sends me a PDF (because they can’t find their original document), I convert that PDF to text and then import that over into InDesign. When the PDF is converted to text, random “hard returns” will show up. (Of course, maybe the client put them in there originally instead of just allowing the text to flow naturally.) But anyway, I have “hard returns” in the middle of a sentence, and this occurs in several sentences throught the often very-long documents.

      Sample:

      I’m a little teapot short(hard return)
      and stout.

      So I do a GREP search for “any lowercase letter+standard carriage return+any lowercase letter”. And this helps me find all the instances, which is great.

      However, is there a formula I could use to get it to KEEP the “any lowercase letter”, replace the “standard carriage return” with a “space”, and then KEEP the second “any lowercase letter”?

      Or am I going about this the completely wrong way?

    • #74452
      Aaron Troia
      Participant

      Hey Melinda,

      No you’re not going about it the wrong way, actually that’s a good use of GREP, try this

      Find: ([a-z])\n([a-z])
      Replace: $1 $2

      You can always add more characters in the first capture group such as a closing parenthesis like you have in your sample to catch more characters before the hard return.

    • #74522

      Thank you.

      Okay, I know there are no stupid questions, so I’m not going to feel bad about asking this next question, lol.

      I tried that before posting and it just replaces the found text with the actual text of $1 $2. (I did use the “Found” character set to insert the $1 and $2. I also tried $1 and $3, because my thought is those are strings, right? so the first lowercase letter is $1, the hard return is $2, and the second lowercase letter is $3. In my thought process.)

      So I am apparently doing something wrong. Do I need to enclose it somehow?

      Sample:

      I’m a little teapot shor$1$2nd stout.

    • #74523
      David Blatner
      Keymaster

      That’s odd. You are in the GREP tab of the Find/Change dialog box? (Not the normal Text tab.)

    • #74524

      I figured it out. I had to enclose each section of text in parenthesis.

      So my find is:

      (/l)(~b)(/l)

      and my change to is

      $1 $3

    • #81826
      Carey Martin
      Member

      This is exactly what I want (change wildcard digitmo to wildcard digitm. But I am a GREP virgin. I found the grep tab on the find/change box, entered what I needed in the fine what, but how do I enter the new text into the change to bit? I’m going to need this a lot as I am working through dozens of tables making this change.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
>
Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo