Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Apply character style to capitalized names – GREP?

Return to Member Forum

  • Author
    Posts
    • #63416

      Let's say I have several paragraphs that contain people's names, like a celebrity news column. How would I apply a character style (e.g., bold) to the names only? Would this be a job for GREP? I basically want to look for two capitalized words in a row, such as:

      Singer Mick Jagger said the Rolling Stones had rehearsed around 70 songs for a series of 50th anniversary concerts later this year, and guitarist Keith Richards assured fans the veteran British rockers would “deliver”.

      I don't know GREP beyond what's built into ID, so help me out here. Thanks.

    • #63418

      What you ask is certainly possible, and in (at least!) two different ways. First, you can use GREP to search for this

      bul+ ul+b

      and manually apply bold (or put “Bold” in the Change To formatting field, and use any of the Change/Change Next/Change All buttons).

      Second, a way faster method, by adding a GREP style to your paragraph style. You can use the same GREP for this; all names will automatically be bolded.

      If you may have three or more names (“David Lee Roth” comes to mind :D), use this GREP:

      bul+( ul+)+b

      There is a possible problem, though. It is right there in your example! “Singer Mick Jagger” — that's three capitalized words in a row, but the “Singer” is not part of a name. If you manually apply your bold, you can always adjust it later on, but when you want to use a GREP style you're pretty much stuck to it. Depending on your text, you could try this

      (?<=.)bul+( ul+)+b

      which will ignore the very first word, even if it starts with a capital. You can even tell GREP to ignore the specific word “Singer”:

      (?!Singer)bul+( ul+)+b

      .. but perhaps you also have a “Singer/songwriter”, a “Musician”, “Guitar Hero”, or “Ex Genesis Drummer and Singer” ..

    • #63423

      Thank you so much – I will give it a try with a paragraph style. I'm wondering if I can apply a character style that I've already created, rather than simple bolding. For example, one with a yellow highlight that I've made with an offset underline.

    • #63424

      The best all-around guide is Peter Kahrel's O'Reilly Shortcut on GREP for InDesign: https://shop.oreilly.com/produc&#8230;..6156015.do

      But the very short version: b is a word break, u stands for a single uppercase character, l for a single lowercase character. InDesign's GREP even recognizes Greek or Cyrillic uppercase and lowercase characters as such (not that I think Greek names to pop up in your articles — George Michael doesn't count! he's spelled in Latin!)

      The '+' means “one or more of the preceding code”, so something like l+ means “one or more lowercase characters). The parentheses group stuff together in a functional unit; (ul)+ means “find one uppercase, then one or lots of lowercase characters; repeat this unit as much as possible”. As you see, GREP is quite concise compared to English :)

    • #63425

      Thanks again – I have a lot to learn, but I find this stuff very interesting!

    • #63442
      Chuck Nigash
      Member

      Theunis, you make it look so easy. :-)

      Nice thread. And I second the motion on Peter's book. Fantastic recipe for success. ALSO: The title of Peter's book has CS3 & 4 in there…. but GREP for ID hasnt changed and everything is still valid. Best $10 or so you can spend on one of the best guys here too.

    • #63446
      Chuck Nigash
      Member

      Sooooo, Theunis, just for kicks I tried something related to this on for size:

      (?<=.)bu+

      CONTRIBUTORS: ILLUSTRATOR, JONGWARE, NIGASH

      Hoped for change to … CONTRIBUTORS: Illustrator, Jongware, Nigash

      This cleverly skips the category “CONTRIBUTORS:” and selects the names … Now, let's say the names should all be lowercase. It gets sticky. I created a character style based on Normal, but that had no effect.

      I basically tried to change typed caps to lowercase as an extension of this thread. If Adobe's Ch Styles supported lowercase, it'd work. Even more cool would be to look back and hold the first Cap and change the rest of the word to lc, but that'd be magic and probably lean on jsx.

    • #63447

      Chuck, InDesign's flavor of GREP cannot change uppercase to lowercase. Using a character style, you can change lowercase to uppercase only because “Capitals” is a text attribute — it does not change the actual text, as you can see by copying and pasting it into the Find What field, for example.

Viewing 7 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads