GREP: Find text assigned an [A] style

Learn / Forums / General InDesign Topics / GREP: Find text assigned an [A] style

Tagged: ,

Viewing 5 reply threads
  • Author
    Posts
    • #76324
      Tom Hybert
      Member

      Hey guys,

      I’m sure this is super simple but I can’t for the life of me work it out. I have some text formatted by a copyeditor with tags like this:

      [A]Count the toys
      [Act]Count the toys. Write the number.
      [G]Children count the toys in each box and then write down the number.
      Some children may find it helpful to match each object with a counter or cube to support their counting.
      [Footer]Counting to find out how many, writing the number

      I want to apply paragraph styles to those tagged lines using grep. Presumeably I need to get it to look for text following [A] but before the next [ and then apply an A style to that. How do I go about that?

      Thanks,
      Tom

    • #76325
      David Blatner
      Keymaster

      One way to do that is to use the findchangebylist.jsx script. Another way is to use MultiFindChange from automatication.com
      Just search for [A] and delete it and apply the A paragraph style:
      https://creativepro.com/use-findchange-to-delete-in-indesign.php

    • #76326
      Tom Hybert
      Member

      Thanks David,

      I need to look for all the text that comes after the [A] tag and assign it a paragraph style. There may be multiple paragraphs so it needs to look for the next square bracket tag to know where to stop assigning the style I think.

      I’ll have a look at the scripts you posted.

      Most appreciated, thanks.

    • #76327
      David Blatner
      Keymaster

      So not all paragraphs are tagged? So it might look like:
      [A]first paragraph
      second paragraph
      third paragraph
      [B]fourth paragraph

      Is that correct? in that case you would search in the GREP tab for:
      (?s)^\[A\](.+?)(?=\[)
      and then apply the paragraph style A
      That grep means “apply this to more than one paragraph, then starting at the beginning of the paragraph, search for [A] followed by any text up to, but not including, another [”

    • #76328
      Tom Hybert
      Member

      David you’re a bloomin’ genius. Thanks so much.

    • #76329
      David Blatner
      Keymaster

      Glad that worked for you! Then, if you find yourself doing 5 or 10 or more of these find/change queries in a row (each for a different paragraph style), that’s when you want MultiFindChange or findchangebylist.

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