Using GREP to easily format subheads.

Learn / Forums / General InDesign Topics / Using GREP to easily format subheads.

Viewing 4 reply threads
  • Author
    Posts
    • #79625
      John Tierney
      Member

      I have some raw text I am placing into an indesign document. I want to use GREP within the Find and Replace to find paragraphs with less than 35 characters which are preceded by two paragraph breaks. Then I can just replace the text using $1 and change the style at the same time. How do I find this?

      I figured the expression would look something like:

      \r\r(.{35})

      But I am not sure how to ask it to look for only 1 to 35 characters.

    • #79626
      David Blatner
      Keymaster

      This code should find all paragraphs up to 35 characters long:
      ^.{1,35}$

    • #79627

      Ahh, I see you have a response from Mr. Blatner himself…awesome!
      :)

    • #79629
      John Tierney
      Member

      Thank you very much. I will give that a go.

    • #79630
      John Tierney
      Member

      Right this is what I have done in the “Find and Replace” dialog.

      Find:

      (?<=\r\r)(^.{3,60}$)

      This allows me to find a short paragraph which is preceded by two paragraph breaks (which is how I am indicating the start of a subhead in my raw text). In my style sheet box I have set “Body text” so it will ignore any heads which have set themselves automatically when I have used Object styling.

      Replace:

      $1

      With style sheet set to “Subhead”.

      I then go back at the end and replace my double paragraph breaks with single paragraph breaks.

      Simples.

      Thanks.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
>