8 Replies Latest reply: Apr 13, 2012 12:40 PM by Manish-Sharma RSS

    Grep style - add brackets around number

    wbset09 Community Member

      Hi there,

       

      I am wondering if there is a way to use GREP styles to apply brackets around a number. I am looking for it to be a grep style (within the paragraph style) and not a find and replace.

      This will be used in an automated table of contents where the page number will be in brackets. (Is this something I can specify in TOC settings?)

       

      Like such:

       

      Contents

      Chapter One     [3]

      Chapter Two     [10]

      Chapter Three  [15]

       

      Again, it needs to be part of the paragraph style (or TOC settigns) so the brackets are automatically applied to numbers when the associated paragraph style is used.

       

      Hope someone can help me out!

      Thanks!

        • 1. Re: Grep style - add brackets around number
          P Spier CommunityMVP

          GREP styles cannot add glyphs. While you can add the braracket before the number in the TOD settings, there is no way I know to add it after other than find/change or possibly a script.

          • 2. Re: Grep style - add brackets around number
            Manish-Sharma Employee Hosts

            Try this:-

             

            Go to Edit-->Table of Cotents

             

            in the Tabke of Content dialog box , click on "more options" to have the complete options (by default some are hidden)

             

            In the Table of Content dialog box , look for "Between Entry and Number" , there would be text "^t" (basically this is the tab character) , after this type "[" , so the

            complete text in "Between Entry and Number" will look like "^t["

             

            Then Update your table of content , and every entry in your table of content will have the "[" infront of it....now it will much easire to run "GREP"

             

            -----------------------------------------------------

             

             

            Go to Edit-->Find/change

             

            go to GREP tab

             

            In "Find what" put:-  \[\d+

             

            In "Change to" :- $0]

             

            now , click on the "find next' to see the entry of the Table of content and "Change' to change the entry to like [3], [4] etc

             

            Drawback of this workflow:--  Every entry in the document will be serached not only the TOC hence if incase your document has entry of kind :- [356 , [34 , they will be searched and changed so be cautious for that

            • 3. Re: Grep style - add brackets around number
              P Spier CommunityMVP

              There is no particular advantage to adding the bracket before the number in the TOC since you have to run the find/change anyway.

               

              You can search for \t(\d+) and chage to [$1] and get the same thing without adding the bracket first.

               

              Also, there is no need to search the entire document. Set the scope of the search to Story and only the TOC will be affected (TOC must always be a self-contained story).

              • 4. Re: Grep style - add brackets around number
                Manish-Sharma Employee Hosts

                Great point, I believe I overthink sometime.

                • 5. Re: Grep style - add brackets around number
                  P Spier CommunityMVP

                  Don't we all.

                  • 6. Re: Grep style - add brackets around number
                    wbset09 Community Member

                    Thank you everyone!

                    I appreciate the responses. Maybe at some point GREP styles will be able to add glyphs, wouldn't that make things easier! ha.

                    • 7. Re: Grep style - add brackets around number
                      P Spier CommunityMVP

                      Styles have never been intended to add content, and never will be (aside from things like underlines, paragraph rules and bullets and list nembers, all of which are considered "adornments" and cannot be selected).

                      • 8. Re: Grep style - add brackets around number
                        Manish-Sharma Employee Hosts

                        Think in this way, Glyphs is not defined set , every font has its on Glyph sets

                         

                        and in that set every glyph has its own Unicode , which is Unique.....to include it in the GREP , we have to make the GREP font dependent ......and GREP will loose its basic functionality because it will not be able to serach the document just the fonts.

                         

                         

                        Hence including Glyphs in GREP will screw up the things