3 Replies Latest reply on Nov 22, 2014 4:39 AM by Peter Spier

    GREP

    siddiqjouve

      Hi,

       

      How to find a space in Grep which is after a character style in a paragraph.

       

      I have attached the screenshot. I want to find a space after a word conformity and change it to n-dash.

       

      Screen shot 2014-11-22 at 4.03.36 PM.png

       

      Thanks

      Siddiq

        • 1. Re: GREP
          Peter Spier Most Valuable Participant (Moderator)

          GREP cannot find a character after a style or after formatting, unless that space also has the same formatting applied and you use it as a filter, so ou could find a bold space after bold text (because you can limit the search to only bold), but you cannot find a bold space only after yellow italic text because they do not share the same formatting.

           

          What you can do is find the word before the space, change to the same text PLUS a new marker character of some sort that would not otherwise occur before a space, then find the marker/space combination and change to the dash. So that might look like Find .+ with the find formatting set to your character style, Change $0ZZZZ, Find ZZZZ\s with no find formatting specified, Change ~= and set the change formatting to whatever you need for the dash.

           

          That said, IF the dash is always going to be after the first word in your paragraph you could find ^(\S+)(\x{0020}) and replace with $1~=

          That finds anything from the beginning of the paragraph that is not white space, followed by the regular space bar space character (so it won't find a tab or any fixed width or non-breaking spaces) and replaced it with the same non-whitespace characters and the en dash.

          • 2. Re: GREP
            Obi-wan Kenobi Adobe Community Professional

            Hi Peter,

             

            About your comment:

            "GREP cannot find a character after a style or after formatting, unless that space also has the same formatting applied and you use it as a filter, so you could find a bold space after bold text (because you can limit the search to only bold), but you cannot find a bold space only after yellow italic text because they do not share the same formatting."

             

            Not exactly right! 

             

            Capture d’écran 2014-11-22 à 13.07.41.png

            Capture d’écran 2014-11-22 à 13.08.09.png

            • 3. Re: GREP
              Peter Spier Most Valuable Participant (Moderator)

              Ah. Very clever.

               

              Obi-Wan is using a NEGATIVE lookbehind to find spaces that are not preceded by characters that have the same foramting as the space, rather than looking for a particular style and finding spaces that follow it.