2 Replies Latest reply on Jan 8, 2013 5:47 PM by Peter Spier

    GREP style question

    Jeffrey_Smith Most Valuable Participant

      Looking for a GREP style to find text within parenthesis and including the parenthesis, but only if text contains a hyphen. Here is an example: through out the copy there will be pronunciations i.e. Diagnostic (die-ag-NOS-tik) which I want to find this situation and apply a character style, but not the following: Intravenous (IV). TIA

        • 1. Re: GREP style question
          SJRiegel Adobe Community Professional & MVP

          On my way out the door, but see if this works for you. I did a small test, and it seems to, but I haven't tried all the variables.

           

          (\()([\l\u]+(-))+([\l\u]+)(\))

           

          Here's the What the Grep breakdown:

           

          (\()([\l\u]+(-))+([\l\u]+)(\))

           

          (     Begin Group #1

              \(     Literal opening parenthesis

          )     End Group #1

          (     Begin Group #2

              [     Inclusion: any character in this group

                  \l     Any lowercase character (a..z)

                  \u     Any uppercase character (A..Z)

              ]     End Inclusion Group

              +     Any character in this group may occur once or more times; longest possible match will be taken

              (     Begin Group #3

                  -     Literal character “-”

              )     End Group #3

          )     End Group #2

          +     The entire Group #2 may occur once or more times; longest possible match will be taken

          (     Begin Group #4

              [     Inclusion: any character in this group

                  \l     Any lowercase character (a..z)

                  \u     Any uppercase character (A..Z)

              ]     End Inclusion Group

              +     Any character in this group may occur once or more times; longest possible match will be taken

          )     End Group #4

          (     Begin Group #5

              \)     Literal closing parenthesis

          )     End Group #5

          • 2. Re: GREP style question
            Peter Spier Most Valuable Participant (Moderator)

            Based on the description of any text with a hyphen between parentheses that seems overly complex to me. I'd use

             

            \(.+?-.+?\)

             

            that's the openin parenthesis, any text up to a hypehen (shorest match), the hyphen itself, any additional text up to a close parenthesis (shortest match) and the close parenthesis itself. This will match more than a single word in a string between parentheses if at least one contains a hyphen.

            1 person found this helpful