Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Grep query to find start of third sentence, or fourth, or second…?

Return to Member Forum

  • Author
    Posts
    • #62214
      Anonymous
      Inactive

      Hi,

      I'm trying to work out a Grep query to search for a particular sentence, e.g. the start of the third sentence.

      This is because I wish to paste a different icon at the start of each sentence, a bit like different bullet points. Each type of “bullet” must always appear with its particular sentence. For example, a square with sentence 1. A triangle with sentence 2. A circle with sentence 3.

      One thing that gives me hope of finding a solution is that there are always five sentences, separated by an end of paragraph r. However, some of the sentences have commas, and some have a forced line break n.

      For example:

      (SQUARE) This is the first sentence

      (TRIANGLE) This is the second, which

      breaks over two lines

      (CIRCLE) This is the third

      (CROSS) The fourth has some, commas, too

      (OBLONG) The last sentence is here

      The query would get me to the start of the chosen sentence, e.g. start of fourth sentence, where I can paste its specific icon. I then use the query again but slightly modified to get to the start of the, let's say, second sentence. And so on…

      Is this possible with Grep?

      Many thanks if you can help at all.

    • #62225
      Anonymous
      Inactive

      Unless someone comes up with something better, I can probably get the following to work for me as long as I use it correctly.

      (^.+(?!n)r|^.+n.+r|^.+$)

      Finds a sentence with any number of characters, with or without a forced line break, or if it finishes at the end of a paragraph. That expression is then duplicated five times:

      (^.+(?!n)r|^.+n.+r|^.+$)(^.+(?!n)r|^.+n.+r|^.+$)(^.+(?!n)r|^.+n.+r|^.+$)(^.+(?!n)r|^.+n.+r|^.+$)(^.+(?!n)r|^.+n.+r|^.+$)

      In the replace field I put ~c in-between the sentence I want my icon to be pasted (spaces only included to make it easier to see).

      For example:

      $1$2$3 ~c $4$5

      The icon (or rather, the contents of the clipboard) will go before sentence 4.

    • #62226
      Anonymous
      Inactive

      This works to a certain extent. But removes the icons already pasted in in previous lines. The head-scratching continues.

    • #62227
      Anonymous
      Inactive

      Sorted. A few more steps but gets around losing previous icons and tripping up over multiple forced line breaks.

      Steps as follows:

      Find forced line break:

      n

      Replace with something weird:

      ||||

      Find the five sentences:

      (^.+r|^.+$)(^.+r|^.+$)(^.+r|^.+$)(^.+r|^.+$)(^.+r|^.+$)

      Replace, putting something meaningful before each one:

      [ONE]$1[TWO]$2[THREE]$3[FOUR]$4[FIVE]$5

      Find each new word, e.g. [THREE], and replace with the relevant icon, pasting it from the clipboard.

      Find:

      [THREE]

      Replace:

      ~c

      Find removed forced line breaks:

      ||||

      Replace with forced line breaks:

      n

Viewing 3 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads