2 Replies Latest reply on Dec 4, 2015 9:20 AM by wardb16788506

    GREP replace retaining text overrides

    wardb16788506

      Hello,

      GREP search and replace seems to leave local overrides on the position of the text rather than transferring them with the text where they were originally associated.

      Find what: (^[^~y]+) ([^\r]+)

      Change to: $2~y$1


      ORIGINAL: BOOK SECTION          100—TITLE, cont. (2)

      REPLACED: 100—TITLE, CONT.          (2) BOOk seCTION


      If the examples formatted correctly in this post, we're looking for anything that's not a right tab, followed by a right tab, and then anything not a paragraph. Then I just want to swap the captured data on either side of the tab. This paragraph style is formatted as all caps with "cont" being lowercase with local overrides. When replaced, the location of the formatting remains which is not the behavior I'd expect or looking for. My desired lowercase text is now uppercase and a new undesired portion is now formatted locally.

       

      I know I can get around this via character styles applied or even nested GREP, but that's not always practical in this case. Is there a setting I'm missing here, or is this maybe an  undocumented bug? Thanks in advance.

        • 1. Re: GREP replace retaining text overrides
          Peter Kahrel Adobe Community Professional & MVP

          You're not missing anything, and it's not really a bug. Grep replacements are just text replacements. You can manipulate formatting by explicitly setting it in the Find format and Change format panels, but if you leave those panels empty InDesign simply ignores formatting. InDesign's formatting is not physically attached, so to speak, to text ranges; rather there some part in the document with information that says 'apply allcaps to characters 10-30 in story 212'. That information isn't changed when you replace text, and that's why you see the effects that you see.

           

          You can't get around that by using character styles just likie that, only by using nested or grep styles. The only other way I know of dealing with these things is to replace formatting with text tags, do your replacements, then change the text tags back to formatting. In your case you would replace allcaps with tags so that your line would read something like

           

          <ac>book section    100—title,</ac> cont. (2)

           

          Then do your replacements and revert the tags to allcaps formatting. Sound very cumbersome but it's quick and easy to script.

           

          Peter

          • 2. Re: GREP replace retaining text overrides
            wardb16788506 Level 1

            Interesting approach, Peter. I hadn't thought of text tags. It makes perfect sense that the formatting is applied to character position and not the text. As a followup, I can loop and check which characters have overrides (it's a R/O boolean property), but is it possible to determine what the specific overrides characters have applied?