Grep – find second word in Par

Learn / Forums / General InDesign Topics / Grep – find second word in Par

Viewing 4 reply threads
  • Author
    Posts
    • #75082
      ohad nanach
      Member

      Hi all,

      I need help finding the second word in each paragraph with grep.

      Thanks in advance

    • #75084
      Aaron Troia
      Participant

      That’s a tough one Ohad, there are many variables both before and after both the first and second words to account for, but this is what I came up with so far, it still doesn’t catch every second word but it’s a start.

      ^[^ ]+ \K\w+([’\w]+)?(?=[,])?

    • #75087
      ohad nanach
      Member

      Hi Ron,
      I basically need to insert an anchored object (which is copied to the clipboard) right before the 3rd word in the paragraph.
      does it make it simpler for you? thanks

    • #75089
      Aaron Troia
      Participant

      Ohad, that does make it easier, I thought you were trying to isolate the second word, but that extra bit of information really helps. So depending on whether you want to place the anchored object before or after the space after the second word,

      before the space:

      Find: ^([^ ]+ [^ ]+)(?= )
      Replace: $1~c

      or after the space:

      Find: ^([^ ]+ [^ ]+ )
      Replace: $1~c

      Let me know if that works or not for you.

    • #75090
      ohad nanach
      Member

      That works great! Thanks much for your help ++

Viewing 4 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