9 Replies Latest reply on Mar 1, 2014 7:41 AM by jaal

    A Difficult Question for ID Hotshots

    jaal Level 1

      I have a sort of dictionary in which each term is formatted with a bold char. tag followed by 2 non-breaking spaces then followed by a definition formatted with an ital. char. tag. What I would like to do is automatically reformat the text in reverse so that the the definition is first followed by the non-breaking spaces and the bold text. for example:

       

      Agneau  lamb I would like to change to lamb  Agneau

       

      This would allow me to use these para. tags and with ToC "alphabetical sort" tool to make a new text file in alphabetical order according to the english word. Thereby making an english listing from the french one.


      I hope I make myself clear

       

      Thanks for any insights!!

        • 1. Re: A Difficult Question for ID Hotshots
          Joel Cherney Adobe Community Professional & MVP

          This sounds not hard, actually, assuming that the only place in the whole document you find two NBSP in a row is in these definitions. I would use a GREP query to do this change.

           

          Start by opening up a Find/Change window, then go to the GREP tab. In "Find what" use this query:

           

          (.+)~S~S(.+)

           

          and in the "Change to" use this:

           

          $2~S~S$1

           

          This finds any group $1 of letters followed by two NBSP followed by any group $2 of two letters, and then replaces with group $2, two NBSP, and then group $1.

          1 person found this helpful
          • 2. Re: A Difficult Question for ID Hotshots
            Joel Cherney Adobe Community Professional & MVP

            Actually, upon further testing, I see that the character styles refuse to follow along. Kind of a surprise, really. If the character styles for bold and for italic are unique to this list, it'd be really easy to edit them after applying the GREP.

            • 3. Re: A Difficult Question for ID Hotshots
              Peter Spier Most Valuable Participant (Moderator)

              It's normal for the character styles to stay inthe same postion, BUT, in this case all of the styleing can be accomplished in the Paragraph style using nested styles.

               

              Style 1 up to 1 NBSP, then the other style as the base for the paragraph, or None through 2 NBSP, then style 1.

               

              And I'd revise the grep to find (.+)(~S~S)(.+) and change to $3$2$1

              • 4. Re: A Difficult Question for ID Hotshots
                jaal Level 1

                Thank you Peter and Joel. It's friday evening here but will give this a try tomorrow morning and will post my results. Thanks so much!

                • 5. Re: A Difficult Question for ID Hotshots
                  Obi-wan Kenobi Adobe Community Professional

                  Hi,

                   

                  One click! using Multi-Find/Change.

                   

                  Process:

                   

                  As we define:

                  Char Style 1 (CS1) = Bold

                  Char Style 2 (CS2) = Ital

                   

                  Regex 1:

                   

                  Search: [^~S].+

                  Replace: #CS1$0#CS1

                  Search format: CS1

                   

                  Regex 2:

                   

                  Search: [^$].+

                  Replace: #CS2$0#CS2

                  Search format: CS2

                   

                  Regex 3:

                   

                  Search: (#CS1)(.+)(#CS1)(~S~S)(#CS2.+#CS2)

                  Replace: $5$4$2

                  Replace by format: CS1

                   

                  Regex 4:

                   

                  Search: (#CS2)(.+)(#CS2)(~S~S)

                  Replace: $2$4

                  Replace by format: CS2

                   

                  Regex 5:

                   

                  Search: ~S~S

                  Replace by format: None

                   

                  Good Night! 

                  1 person found this helpful
                  • 6. Re: A Difficult Question for ID Hotshots
                    Obi-wan Kenobi Adobe Community Professional

                    ... Another way:

                     

                    if we put 1 en-space between "Agneau" and "Lamb" and 2 non-breaking spaces after "Lamb" and if we define the paragraph style with 2 Grep style as:

                     

                    Grep style 1: Apply style "Bold" to: .[^~S+]+~>

                    Grep style 1: Apply style "Ital" to: .[^~>]+~S~S

                     

                    We only have to make the regex below:

                     

                    Search: (.+~>)(.+~S~S)

                    Replace: $2$1

                     

                    ... and it is unnecessary to apply character styles ... These are the two Grep styles which do it! Cool! 

                    • 7. Re: A Difficult Question for ID Hotshots
                      Peter Spier Most Valuable Participant (Moderator)

                      Obi-Wan,

                       

                      While GREP styles are cool, and fun to do, they really are overkill for this, and using them unnecessarily is a real performace killer. In this case we have a clear boundary between the styles, the two non-breaking spaces, and an ordinary nested style is more efficient and approrpiate. If you are searching for a string that might be anyplace in the paragraph, then GREP style is the way to go, but not here.

                      • 8. Re: A Difficult Question for ID Hotshots
                        Obi-wan Kenobi Adobe Community Professional

                        Hi Peter,

                         

                        I totally agree with you.

                        In ID, we have an extensive range (nested style, grep style and research) to manipulate text. Everything depends on the context. Assuming Jaal and see what he wants to do, your approach is the best and the most efficient and, in this case, I would do it completely as you propose. 

                        • 9. Re: A Difficult Question for ID Hotshots
                          jaal Level 1

                          Thanks Peter, Joel and Obi. You guys help to make this forum the exceptional resource that has gotten me out of binds for many years now.

                          Thanks!