3 Replies Latest reply on May 29, 2017 3:38 AM by Obi-wan Kenobi

    find between brackets

    gert verrept Level 2

      FIND

      \(([^()]|(?R))*\)

      CHANGE

      italic (char style)

       

      gives

       

      (sunt quaepta (tiorepta perovit aliquibus) dem)

       

      The grep above finds what is between brackets, but I want it to find the whole text between the exterior brackets, but without the brackets.

      getting it so:

       

      (sunt quaepta (tiorepta perovit aliquibus) dem)

        • 1. Re: find between brackets
          [Jongware] Most Valuable Participant

          This will do the job, but extremely literally: it will only and exclusively match the outer parenthesized phrase (sans parens) when there is a single parenthesized expression within.

           

          (?<=\()[^()\r]*\([^()\r]*\)[^()\r]*(?=\))

           

          Close enough? I don't think it can be adjusted to account for "either/or". In that case you're probably better off just replacing all of the text with italics, and then selectively remove it from just the outermost parentheses.

          • 2. Re: find between brackets
            dhafirp16891848 Level 1

            Hi gert verrept,

            Try this by one click:

            (?<=\))[^\(]+?(?=\))|(?<=\()[^\(]+?(?=\))|(?<=\()[^\(]+?(?=\()

            DSC04560.jpg

            • 3. Re: find between brackets
              Obi-wan Kenobi Adobe Community Professional

              Hi,

               

              Jongware's way works only in one case: double-parenthesis between parenthesis.

              Dhafir's one only catches the text not the parenthesis.

               

              This one uses the Grep recursive code Gert indicates us [ ]. To do what he wants to get [in all situations], just play 2 regex [+ 3rd optional]:

               

              Capture d’écran 2017-05-29 à 12.24.25.png

              Capture d’écran 2017-05-29 à 12.26.32.png

              Capture d’écran 2017-05-29 à 12.26.55.png

               

              (^/)