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

Greps Search Question

Return to Member Forum

  • Author
    Posts
    • #75814
      clyde bielss
      Member

      I’m very very new to greps and I’m trying to write a search that will find tags we use and change the format between the tags but i’m having problems with the character [ used in our tags.

      I want to search [bold] with any word or group of words here [bold] and format the text between with a font style.

      thank you in advance.

    • #75815
      Anonymous
      Inactive

      (?<=\[).+?(?=\])

      (?<=) is a positive lookbehind (it looks but does not include in the find

      \[ is an open bracket, you need to escape the open bracket with a backslash

      .+ is any character
      ? is a qualifier for the shortest match, so stop and don’t find more than the shortest match

      (?=) is a positive lookahead
      \] is a closed bracket

      All together, it’s – look for an open bracket but don’t include it, then find any text in it’s shortest string, up to, but don’t include a closed bracket.

      This finds all text within a [….]

    • #75816
      clyde bielss
      Member

      you are amazing sir! thank you

    • #75817
      clyde bielss
      Member

      the code i was looking for will really be (?<=\[bold]).+?(?=\[bold])

      but your help is amazing :)

    • #75818
      Masood Ahmad
      Participant

      Clyde, what do you mean by [bold]. Is it a bold character or is it the word ‘bold’ within the square brackets.

      If it is the word ‘bold’ within square brackets then here is the code for you:

      Find What: (?<=(\[bold\])).+?(?=(\[bold\]))

    • #75819
      clyde bielss
      Member

      it is the word bold in the brackets – our copy writers use tags in copy like [bold], [header] and so on. so i want to make is so it does what the tag says then deletes the tags they make.

    • #75820
      Masood Ahmad
      Participant

      Then this will suit you best:

      Find What: (?<=(\[bold\])).+?(?=(\[bold\]))
      Change to: Change Format: bold character style

      Hope this works :)

    • #75821
      clyde bielss
      Member

      your code works great, but is there a way to delete the [bold] tags in the same line without having to run a find replace?

    • #75822
      clyde bielss
      Member

      awesome i’ll try that :)

    • #75823
      Masood Ahmad
      Participant

      Yes there is:

      Find What: (\[bold\])(.+?)(\[bold\])
      Change to: $2
      Change Format: bold character style

    • #75824
      Anonymous
      Inactive

      Hmmm.. I see I’m not needed here – good work :)

    • #75825
      Masood Ahmad
      Participant

      Eugene, your suggestions are always welcome. I too have learned a lot from your replies. You’re amazing. Your help is and will always be needed. It is just that I love GREP, and wants to explore more…

      Please don’t take it otherwise :)

    • #75826
      clyde bielss
      Member

      yes eugene your help earlier was awesome :) all of these reply have given me a better understanding of what is going on :)

    • #75830
      Anonymous
      Inactive

      Guys, relax, I was kidding – the smiley face didn’t come through :)

      GREP is amazing, and Masood is very good at it, it’s always good to have other forum users with extraordinary abilities too.

    • #75834
      Masood Ahmad
      Participant

      The smiley :) :) :) :) is here…

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