15 Replies Latest reply on Jul 5, 2011 11:57 AM by Eugene Tyson

    GREP Style, 3 words, only first letter cap

    Eugene Tyson Adobe Community Professional & MVP

      As an example

       

      national college dublin

       

      And I want only the N C D to be caps always

       

       

      Possible to do in a GREP Style?

        • 1. Re: GREP Style, 3 words, only first letter cap
          [Jongware] Most Valuable Participant

          Of course it's possible, but mind you: a GREP style is applied to a paragraph, so every word will be capitalized!

           

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

           

          (where you'd apply a character style that sets Caps). I don't think there is an easy way to restrict it to any three words in sequence, anywhere inside a paragraph. That's because this needs a lookahead -- you need a lowercase character followed by more lowercases that do NOT need the character style applied -- and you cannot string a number of lookaheads together whilst still applying the style to the characters "in between".

           

          Since this is a relevant change, and not just some fancy text formatting, I'd advise to assign a hot key to Title Case and change it the hard way.

          1 person found this helpful
          • 2. Re: GREP Style, 3 words, only first letter cap
            Eugene Tyson Adobe Community Professional & MVP

            Thanks that gave me an idea - do it as string of "ors" with look arounds?

             

            (n|N)(?=ational (c|C)ollege (d|D)ublin)|(?<=(n|N)ational )(c|C)(?=ollege (d|D)ublin)|(?<=(n|N)ational (c|C)ollege )(d|D)(?=ublin)

             

             

            But it doesn't seem to be working for me?

            • 3. Re: GREP Style, 3 words, only first letter cap
              Eugene Tyson Adobe Community Professional & MVP

              it seems to only find the first word?

               

              But if I put those in individually it finds the letter I want no problem?

               

              What have I missed here?

              • 4. Re: GREP Style, 3 words, only first letter cap
                Eugene Tyson Adobe Community Professional & MVP

                Problem solved

                 

                Put them in as 3 different entries in the Style

                 

                Now it finds them and automatically changes them

                • 5. Re: GREP Style, 3 words, only first letter cap
                  Peter Spier Most Valuable Participant (Moderator)

                  Not tested, but because you are looking for essentially the same string every time, not some set of three random words, I think you could do this in one go with

                   

                  N?n?ational C?c?ollege D?d?ublin

                   

                  and apply Title Case, or just do a non-case-sensitive plain text Find/Change when done and apply the style...

                  • 6. Re: GREP Style, 3 words, only first letter cap
                    Eugene Tyson Adobe Community Professional & MVP

                    Trying to avoid using the find/change and/or doing it manually

                     

                    I've got quite a few of these and they may come from other sources, so I've built up a series of GREPs to change acronymns to upper case, and certain "words" should always be title case.

                     

                    I've built them all into the styles now, so any new copy that is placed will automatically treat the upper and lower case.

                    • 7. Re: GREP Style, 3 words, only first letter cap
                      Peter Spier Most Valuable Participant (Moderator)

                      Eugene Tyson wrote:

                       

                      Trying to avoid using the find/change and/or doing it manually

                      I understand that completely.

                       

                      The only thing about GREP styles is they add a fair amount of overhead to composition, and the more you have, the more you will see slowdown (particularly on a less than stellar machine). As a matter of principle I think a single expression rather than two or three that does the same thing is likely to be more efficient.

                      • 8. Re: GREP Style, 3 words, only first letter cap
                        Eugene Tyson Adobe Community Professional & MVP

                        It's a slippery slope, but I've added about 6 different GREP styles to capitalise acronyms and to capitalise words.

                         

                        The beauty is that it won't capitalise the word national on it's own or college or dublin.

                         

                        It has to be in that sequence.

                         

                        Now, if Title Case was added to the Paragraph or Character style, instead of the choices currently there then I'd be much happier

                        • 9. Re: GREP Style, 3 words, only first letter cap
                          Peter Spier Most Valuable Participant (Moderator)

                          OH, right. I forget that Title Case is not available as a character style, so what I said won't help. It did occur to me while walking the dog, though, (and I forgot to post) that classes would be better than the C?c? type of query. [Cc]ollege would find either version, but not Ccollege or cCollege, as the first one would.

                           

                          Preumably Dublin should always be capitalized, even if not part of the other strings?

                          • 10. Re: GREP Style, 3 words, only first letter cap
                            John Hawkinson Level 5

                            Oh, geeze, guys! Use /[Nn]ational [Cc]ollege [Dd]ublin/ and be done with it!

                            • 11. Re: GREP Style, 3 words, only first letter cap
                              Peter Spier Most Valuable Participant (Moderator)

                              Isn't that what I just said?

                               

                              But it won't work as a GREP STYLE because you can't select Title Case as a character style attribute.

                              • 12. Re: GREP Style, 3 words, only first letter cap
                                John Hawkinson Level 5

                                Argh! I fail at reading comprehension, sorry. Time to go have brunch, I think.

                                My regexp of course doesn't work helpfully as a GREP style for the reason you noted earlier, that you have no ability to specify Title Case.

                                 

                                Though I do think that for this sort of thing, GREP styles are really The Wrong Way To Do It. Bad things will happen if someone cut-and-pastes the text out (they get the wrong version). And you're needlessly forcing ID to do these searches over every graf with the applied style whenever anything in that text changes (or more often), when really it ought to only need to do it once... I understand the appeal, I just wouldn't do it myself -- unless I had to!

                                • 13. Re: GREP Style, 3 words, only first letter cap
                                  Eugene Tyson Adobe Community Professional & MVP

                                  Yeh I wouldn't be doing this if I didn't have to.

                                   

                                  I don't think it's the wrong thing for GREP to do. I really needed it for this particular publication, I can't tell you how many times I've done seraches and searches and searches in this publication to make things upper case where needed.

                                   

                                  The GREP solution really works in THIS particular case.

                                   

                                  I don't know how John can proclaim it's the wrong way to do it and he doesn't even know the context in which I am using it. I left out the details on why I am doing it this way for a reason. Because I didn't really want a debate on the right/wrong way to use GREP.

                                   

                                  If you saw the context in which I am doing this you'd agree it's the best way. But I can't post the actual copy here.

                                   

                                  Fear not, this is not applied to 100's of pages. Only a few. And it's essential that these particular words maintain their upper- and lowercase, especially when receiving new files from various sources.

                                   

                                  That's why I put only exactly what I wanted to do in the opening post.

                                   

                                  I already figured out what I wanted to do and I haven't seen a better way yet.

                                   

                                  Thanks for trying though.

                                  • 14. Re: GREP Style, 3 words, only first letter cap
                                    Eugene Tyson Adobe Community Professional & MVP

                                    Ok the thing with the 3 words - say it is National College Dublin

                                     

                                    Then in the heaings I have

                                     

                                    Welcome to National College Dublin Your Free Guide


                                    Take a Tour of National College Dublin

                                     

                                    Here's a Sample of Student Life at National College Dublin

                                     

                                     

                                    For say about 500 pages.

                                     

                                     

                                    I then make a TOC

                                     

                                    BUT they want the TOC to be Sentence case only!!!

                                     

                                    Now when I insert the TOC it's all Title Case as per the headings

                                     

                                    So I select the TOC - and I go "Sentence case"

                                     

                                    Now I have a TOC to update Acronymns, national college dublin, and about 6 other things

                                     

                                     

                                     

                                    That's why I needed to do it. So the TOC style would automate the upper- and lowercase of the words I need.

                                     

                                     

                                     

                                    What I have built in the Styles works great for this TOC. And saves me a lot of time.

                                     

                                     

                                    Hope that clears things up.

                                    • 15. Re: GREP Style, 3 words, only first letter cap
                                      Eugene Tyson Adobe Community Professional & MVP

                                      And to add to that. The TOC is in a seperate file, it's only opened when I need to update it.

                                       

                                      Good bless the Book Panel.