7 Replies Latest reply on May 24, 2012 9:46 AM by Ph1l1pp

    Grep deletes indexmarkers

    Ph1l1pp

      Hello at all,

      we are working with ID CS5 / ID CS5.5 on Windows.

       

      Description of the problem:

      We are searching one or more paragraphs, located between two ‚markers‘. Using a regular expression, we are looking for:

      <Start marker>\r((\S|\s)+?)\r<End marker>

       

      We want to assign these paragraphs a paragraph style, and delete the start- and end markers, i.e.,

      Replace the whole group by $1 matched from the regexp, and assign it paragraph style ‘Test’

       

      However, when inserting $1, all index markers in the paragraph are discarded.

       

      Does anyone have an idea as to how the index markers can be kept together with the paragraph?

       

      best regards,

      philipp

       

       

        • 1. Re: Grep deletes indexmarkers
          Peter Spier Most Valuable Participant (Moderator)

          First, it looks to me like the way you have your parentheses positioned you are deleting the paragraph breaks at the start and end of the found string. And the "Or" statement seems overly complex since it seems like you want to find everything between the markers.

           

          Have you tried using

           

          <Start marker>(\r.+\r)?<End marker>

           

          I'm also curious to understand the marker positioning in the text. For this expression to work, <Start marker> must actually end the paragraph before the one you want to find, and <End marker> must start the paragraph after. Is that how things are set up?

          • 2. Re: Grep deletes indexmarkers
            Ph1l1pp Level 1

            Hello Mr. Spier,

            my expression in first post works fine, if i have no index marks in the paragraphs which will be formatted. Else they will be lost.

            to answer your question:

            i want to delete the paragraph breaks and i want to find everything between the markers, furthermore

            the marker are set correctly. (The start and end marker are different)

             

            For example:

            Text  Text  Text   Text   Text   Text   Text   Text   Text   Text   Text   Text

            Text   Text    Text    Text    Text    Text    Text   Text  Text  Text  Text. Paragraph Break 

            <Start marker>Paragraph Break

            Text which should be formatted. IndexMark Text which should be formatted.

            Text which should be formatted. Text which should be formatted. Paragraph Break

            Text which should be formatted. Text which should be formatted. Paragraph Break

            Text which should be formatted. Text which should IndexMark be formatted.

            Text which should be formatted. Text which should be formatted.  Paragraph Break

            <End marker>Paragraph Break

            Text  Text  Text   Text   Text   Text   Text   Text   Text   Text   Text   Text

            Text   Text    Text    Text    Text    Text    Text   Text  Text  Text  Text. Paragraph Break

             

            Now it is (with my expression from 1st post):

            Text  Text  Text   Text   Text   Text   Text   Text   Text   Text   Text   Text

            Text   Text    Text    Text    Text    Text    Text   Text  Text  Text  Text. Paragraph Break

            Text which should be formatted. Text which should be formatted.

            Text which should be formatted. Text which should be formatted. Paragraph Break

            Text which should be formatted. Text which should be formatted. Paragraph Break

            Text which should be formatted. Text which should be formatted.

            Text which should be formatted. Text which should be formatted.  Paragraph Break

            Text  Text  Text   Text   Text   Text   Text   Text   Text   Text   Text   Text

            Text   Text    Text    Text    Text    Text    Text   Text  Text  Text  Text. Paragraph Break

             

             

            Should be:

            Text  Text  Text   Text   Text   Text   Text   Text   Text   Text   Text   Text

            Text   Text    Text    Text    Text    Text    Text   Text  Text  Text  Text. Paragraph Break

            Text which should be formatted. IndexMark Text which should be formatted.

            Text which should be formatted. Text which should be formatted. Paragraph Break

            Text which should be formatted. Text which should be formatted. Paragraph Break

            Text which should be formatted. Text which should be IndexMark formatted.

            Text which should be formatted. Text which should be formatted.  Paragraph Break

            Text  Text  Text   Text   Text   Text   Text   Text   Text   Text   Text   Text

            Text   Text    Text    Text    Text    Text    Text   Text  Text  Text  Text. Paragraph Break

             

            So the question is, how can i format one, two or more paragraphs between the start and end marker, automaticly, but the index mark shouldn't be lost?

            • 3. Re: Grep deletes indexmarkers
              Peter Spier Most Valuable Participant (Moderator)

              I don't really know why the marker is lost. It's happening here, too. Might be a bug.

               

              Jongware or Peter Kahrel might know....

              • 4. Re: Grep deletes indexmarkers
                [Jongware] Most Valuable Participant

                Index markers are "invisible" -- or, rather, they should be: they are visible to Find Text but you cannot put them in Change Text. I bet they are not picked up by the GREP expression in the saved set "$1".

                 

                In the first run, just apply your paragraph style -- clear the Change To text for that --, and in two next change operations delete the start and end markers. It needs two changes so that way you don't 'touch' the text in between as well.

                • 5. Re: Grep deletes indexmarkers
                  Ph1l1pp Level 1

                  thanks for your support. the two step method works fine.

                   

                  now i have a further question:

                  i modified a script, so that it moves the text between the markers into an anchored object. Now it seems to be impossible to move the index marks too, or is there any way to do this?

                  • 6. Re: Grep deletes indexmarkers
                    [Jongware] Most Valuable Participant

                    That certainly should be possible. Without seeing your script, I would guess you are moving the ".contents" property of your text (which is analogous to 'just the plain characters, no formatting or specials). To make index markers move along, use the ".move" command on your text.

                    • 7. Re: Grep deletes indexmarkers
                      Ph1l1pp Level 1

                      hey jongware,

                      the snippet i use,  uses the "cut" and "paste" function. I was a bit to rushly with my second question, all i did is to include your mentioned two-step-method. i tried it with a minimal example and it worked.

                       

                      thanks a lot for yout help.

                      have a nice day,

                      Philipp