9 Replies Latest reply on Apr 25, 2014 3:00 AM by Peter Spier

    exclude list for GREP?

    Gwouten Level 1

      Hi everyone,

       

      I am regularly working on annual reports and this is a problem I have come across every time, but still haven't found a solution for:

       

      There are lots of numbers in these reports and depending on the language, the thousands are separated by a "." or a"<thin space>". Also included in this kind of documents are years: 2009, 2010, 2011, etc...

       

      Usually I would use GREP to separate the thousands, but then I also seaparte all the years and I have to GREP again to attach them again.

       

      Ex: 2009 -> 2.009 -> I don't want this!

       

      Is there a way to exclude a number of strings in the GERP-search?

       

      Thanks!

        • 1. Re: exclude list for GREP?
          [Jongware] Most Valuable Participant

          What GREP are you using to insert thousands separators?

          • 2. Re: exclude list for GREP?
            Peter Spier Most Valuable Participant (Moderator)

            That depends on the document and how it was built.

             

            Find/Change queries can be limited in scope to individual stories or selections, or to match specific styles. GREP queries can also use Look-Behinf or Look-Ahead, either positive or negative, to limit matches to cases where there is or is not other text of a certain type that preceeds or follows the found string. I would guess that the best bet here is probably a style-based limit, but you haven't really given us enough detail to say for sure.

            • 3. Re: exclude list for GREP?
              Gwouten Level 1

              Currently i'm doing it like this:

               

              find:

              (\d{1,3})(\d{3})

               

              replace:

              $1.$2

              • 4. Re: exclude list for GREP?
                [Jongware] Most Valuable Participant

                There is not a built-in way to automatically exclude "years" -- if only because, well, what series of digits constitute a year? (Having ran into this problem myself: yes, there *are* authors happily referring to "Dampier, William. 1681. A New Voyage Round the World.", and no: my reference processing scripts are not happy with numbers like these!)

                 

                Try this: a lookahead that forces a no-match on '2009'

                 

                (?!2009\b)(\d{1,3})(\d{3})

                 

                If this works 'good enough', you can expand it to (not) match, for instance, "2000-2014" but beware of the many, many things that can go wrong (consider an amount of "$2009").

                • 5. Re: exclude list for GREP?
                  Gwouten Level 1

                  Ok, thanks!

                   

                  I've always figured that there's no absolute way to exclude a series of digits and differentiate between "this one's a year" and "this one's something else".

                   

                  But I'll go ahead an use your suggestion, with caution

                   

                  Thanks!

                  • 6. Re: exclude list for GREP?
                    Pavel Emi

                    Pls, I used your solution to the separation of thousands (\d{1,3})(\d{3})   , but does not work with large numerals over a million - you have a solution?

                    • 7. Re: exclude list for GREP?
                      Pavel Emi Level 1

                      Pls, I used your solution to the separation of thousands (\d{1,3})(\d{3})   , but does not work with large numerals over a million - you have a solution?

                      • 8. Re: exclude list for GREP?
                        Gwouten Level 1

                        If you simply add another "(\d{3})" to the end of the grep search query and a ".$3" to the replace part like this:

                         

                        search: (\d{1,3})(\d{3})(\d{3})\b

                        replace: $1.$2.$3


                        it will also include millions.

                         

                        You can add this for each multiple of thousand, e.g. 1.000.000.000 would need "(\d{1,3})(\d{3})(\d{3})(\d{3})\b" in the search field and a "$1.$2.$3.$4" in the replace field.

                         

                        I'm sure there are better ways to do this, but this will do if you're in a hurry .

                         

                        I hope that helps!

                        • 9. Re: exclude list for GREP?
                          Peter Spier Most Valuable Participant (Moderator)

                          That method requires a separate search for each multiple of thousands.