6 Replies Latest reply on Sep 23, 2011 3:29 PM by Colin Flashman

    IDCS5/MAC - GREP Style to uppercase a letter after a dash between words

    Colin Flashman Adobe Community Professional

      G'day there.

       

      I'm trying to create a GREP style to uppercase a letter after a dash between words, more specifically where one word starts with a capital and the one after a dash does not e.g. Lorem-ipsum = Lorem-Ipsum

       

      The full story is that there is a standing indesign file used over and over again which data-merges surnames which are in a massive database. The data arrives in uppercase and our mail barcoding software allows us to Title Case certain fields, but the Title Case behaviour has the following results:

       

      * McLeod = Mcleod

      * D'Agostino = D'agostino

      * Smith-Bunting = Smith-bunting

       

      i've been able to solve the McLeod = Mcleod problem with the following GREP style:

       

       

      (?<=Mc)\l
      

       

      and then apply a character style which is nothing more than All Caps.

       

      similarly, i've been able to solve the D'Agostino = D'agostino problem:

       

       

      (?<=\u')\l
      

       

      and once again apply the All Caps style to the affected letter. This also solves the O'leary problem to O'Leary.

       

      However, when I try these GREPs to grab the Smith-bunting style issues:

       

       

      (?<=\u\l+?-)\l     or   (?<=\u\l{2,}-)\l
      

       

      the search won't work, nor will it work with regular Find/Change GREP replace... yet the expression \u\l+?-\l will find the block that i'm after.

       

      I could use the search

       

      (?<=\l-)\l
      

       

      and this will find Smith-bunting = Smith-Bunting... but will also find co-operate = co-Operate (will find two words joined with a dash but  starts with a lower case letter).

       

      This is fine if the para style is applied to the  line in the address block containing the client's name, but if the name is referred to in a block of text, then that block of text has to have the para style with the GREP style applied, and any dashes between words in that para behave the same way as the name.

       

      yes, it is possible to go into excel and use the =PROPER(affected cell) and fix the Smith-Bunting fields, but i'm trying to create a solution which will work solely in InDesign so that other operators in the office (who aren't familiar with excel) can simply open the standing file and dump in the txt database generated by the mail barcoding software.

       

      there are other names that the mail barcoding's title-case fouls up i.e.

       

      * MacLeod = Macleod

      * van der Graaf = Van Der Graaf

      * van Diemen = Van Diemen

       

      but a GREP to make Macleod become MacLeod may foul up Mack, Mackie or Macy to become MacK, MacKie or MacY.

       

      I also know that a GREP for the van der or van won't work as the style will only force letters to become All Caps, not uppercase to lower...

       

      Ultimately...

       

      does anyone know a way to GREP style (not a find/change GREP) a fix for Xxxxx-xxxxx = Xxxxx-Xxxxx?

       

      Colly

      Colecandoo.

        • 1. Re: IDCS5/MAC - GREP Style to uppercase a letter after a dash between words
          [Jongware] Most Valuable Participant

          Only FYI -- it won't help you, but it might give you further ideas to look into:

           

          cdflash wrote:

          [...]  when I try these GREPs to grab the Smith-bunting style issues:

          (?<=\u\l+?-)\l     or   (?<=\u\l{2,}-)\l
          

          the search won't work, nor will it work with regular Find/Change GREP replace... yet the expression \u\l+?-\l will find the block that i'm after.

           

          Alas. Lookahead works with variable length arguments, but lookbehind does not.

          1 person found this helpful
          • 2. Re: IDCS5/MAC - GREP Style to uppercase a letter after a dash between words
            Colin Flashman Adobe Community Professional

            cheers for that bit of info. went onto your site http://www.jongware.com/idgrephelp.html and had a look at the table further down with the (?=regex) table and this made much more sense...

             

            but i've rewritten my GREP and still having difficulty.

             

            to make sure the GREP was working, I started a new doc filled with placeholder text and an instance of Xxxx-xxxx and xxxx-xxxx to make sure that only the former would change and not both.

             

            I came up with this GREP to make sure it would select:

             

            \s\u\l+?-\l

             

            so the following is being grabbed: _Xxxx-xxxx

             

            but when i use the following GREP:

             

            (?!\s\u\l+?)-\l

             

            this ought to find Xxxx-xxxx... and it does, but it ALSO finds xxxx-xxxx... which i did not want it to find.

             

            it looks as if the GREP is ignoring the \s and \u.

             

            i'm glad i shave my head or else i'd tear my hair out... like my avatar!!!

            • 3. Re: IDCS5/MAC - GREP Style to uppercase a letter after a dash between words
              Haakenlid Level 3

              I would write script to solve this. Using GREP styles and all-caps character styles seems like a very clumsy solution that could cause several problems in the long run, even if InDesign's GREP was completely bug free.

              • 4. Re: IDCS5/MAC - GREP Style to uppercase a letter after a dash between words
                Colin Flashman Adobe Community Professional

                in a perfect world... sure. i would use the findchangebylist.jsx and build up a list of things to look for, such as the McX, X'x... and even make a list of words to change such as MacLeod, MacIntosh, van Gastel, etc... and then run it to the text files prior to merging.

                 

                but, the idea of using a GREP style would be so other operators (not just me) who are not as familiar with the more advanced features of indesign (e.g. scripts, GREPs, etc) could open the indesign file and the database would "magically" work, rather than add another step which they would probably see as unnecessary or complicated.

                 

                you should see the SOP we actually have to do this routine job... it's over 32pp long! so adding any more steps to it is something i definitely want to avoid... if anything i want to make this thing as easy as possible for other operators so i can take holidays without calls asking me how to do certain steps, etc.

                • 5. Re: IDCS5/MAC - GREP Style to uppercase a letter after a dash between words
                  [Jongware] Most Valuable Participant

                  I agree with Haakenlid on his Dirty-Workaround view -- I feel data should be entered the way it oguht to, not altered by some magic GREP styling -- but then again I can also sympathize with your POV re: a fire-and-forget solution even your dumbest operator can't miss.

                   

                  Oh the rigors of life.

                   

                  If you are totally, absolutely certain you want to do this by GREP, use this:

                   

                  (a) Set a To Capitals character style to the string

                   

                  \b\u\l+\-\l

                   

                  -- this will magically transform "Hon. Lt. Sir John Forsythe Blunt-object" into "BLUNT-Object".

                   

                  (b) Then override ( ! ) the first half again with another character style that removes the To Capitals attribute ( ! ):

                   

                  \b\u\l+-(?=\l)

                   

                  Notice how this expression is exactly the same as the above one, except for the very last code -- the next lowercase must also be caught, but now using a lookahead so its formatting won't be affected.

                  This removes the All Caps override from the first halve, changing it from "BLUNT-Object" back to "Blunt-Object".

                   

                  Screen shot 2011-09-23 at 11.21.58 PM.png

                   

                  Lots of side effects, I'm sure. Perhaps it is safer to teach your operators to run a single script.

                  • 6. Re: IDCS5/MAC - GREP Style to uppercase a letter after a dash between words
                    Colin Flashman Adobe Community Professional

                    @Jongware:

                     

                    didn't know that GREP styles could search OVER the top of other GREP styles... that's fantastic!!!

                     

                    however, the seeds of doubt are now sewn about issues, so may file this answer as a "possible" solution rather than add it to the SOP.

                     

                    i do agree with yourself and Haakenlid - data should be correctly formatted in the first place.

                     

                    the database arrives in an excel file as all caps. the parts of a database which may be repeated through the text and "speak" to the client are their title (Mr, Ms...), initials, and surname. It wouldn't be a problem if the data was only used in the address block - i'd leave it all as uppercase; but sadly there is typically a "Dear XX XXXXXX", so rather than make it obvious that the data is a stencil letter (e.g. Dear MR JONGWARE), it is title-cased in the mail-barcoding software. To complicate this, the postal service want the mail sorted by regions, so we can't just export one text file out and merge that (that would be too easy)... we have to export each mail region as a text file, so if we have a nationwide campaign this could end up with 30 or so text files to merge!

                     

                    I'm not certain about the source of the Database (excel or a proprietary MIS) but the client is a VIP so putting the onus on them to correct the data is out of the question from the rep's point of view.

                     

                    once again, thank you for the potential solution.