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

GREP Styles problem

Tagged: 

Return to Member Forum

  • Author
    Posts
    • #87886

      Can someone help me out with a GREP problem?

      I have a GREP style to add ordinals to numbers…

      (?<=\d)(st|nd|rd|th)

      Works great. But I also have a paragraph style with a drop cap followed by three words in all OT small caps. When the ordinal appears in this location it is lowercase. I want to override it so it is not formatted as an ordinal, just small cap letters.

      I tried…

      (?<= )(?<=\w+)(?<= )(?<=\w+)(?<= )(?<=\d)(st|nd|rd|th)

      Figuring it would apply to any ordinal that was not the first, second, or third word in the paragraph. But it just turns off the ordinals.
      I think I’m close. I just need a little tweak.

    • #87992
      Matt Isaac
      Participant

      try.. (\w+ ){3}\d\K(st|nd|rd|th).. Let me know if this doesn’t work for you.

    • #88022

      It didn’t work. It loses the ordinals in all places. But here’s what I did: I got rid of the nested style and did everything through GREP.

      1. Apply style Ordinal to
      (?<=\d)(st|nd|rd|th)

      2. Apply style Small Caps to
      ^(\w|\.|,|’)* (\w|\.|,|’)+ (\w|\.|,|’)+ (\w|\.|,|’)+
      There’s a trailing space there.

      3. Apply style Drop Cap to
      ^\w

      It was a bastard.

      A clever GREP parser will see that I have decided to use four words instead of three.

      Is there any tip on how to apply formatting in posts?

    • #88028
      Masood Ahmad
      Participant

      No, you can’t apply formatting in posts here. For the codes, you can use the HTML code tag to help differentiate it from the body text.

      Secondly, it becomes easier for the members to answer to the questions, if some actual text is also supplied by the Post Creator. This way we can first test the solution at our end and then share the same on the Posts.

      We look forward for some more challenging questions from your side.

      • #88101

        Here’s a sample:
        On August 18th, twelve days after the bomb burst, Father Kleinsorge set out on foot for Hiroshima from the Novitiate with his papier-mâché suitcase in his hand. He had begun to think that this bag, in which he kept his valuables, had a talismanic quality, because of the way he had found it after the explosion, standing handle-side up in the doorway of his room, while the desk under which he had previously hidden it was in splinters all over the floor. Now he was using it to carry the yen belonging to the Society of Jesus to the Hiroshima branch of the Yokohama Specie Bank, already reopened in its half-ruined building.</dl>

        It should look like this:

        Ordinal: (?<=\d)(st|nd|rd|th)
        Drop Cap: ^(\w|\.|,|')* (\w|\.|,|')+ (\w|\.|,|')+ (\w|\.|,|')+
        Small Caps: ^\w

    • #88109

      Here’s a better example with ordinals in both places…

      At two minutes after eleven o’clock on the morning of August 9th, the second atomic bomb was dropped, on Nagasaki. It was several days before the survivors of Hiroshima knew they had company, because the Japanese radio and newspapers were being extremely cautious on the subject of the strange weapon.

      On August 9th, Mr. Tanimoto was still working in the park. He went to the suburb of Ushida, where his wife was staying with friends, and got a tent which he had stored there before the bombing. He now took it to the park and set it up as a shelter for some of the wounded who could not move or be moved. Whatever he did in the park, he felt he was being watched by the twenty-year-old girl, Mrs. Kamai, his former neighbor, whom he had seen on the day the bomb exploded, with her dead baby daughter in her arms. She kept the small corpse in her arms for four days, even though it began smelling bad on the second day.

    • #88113

      So, problem solved with your solution?

      The grep for small caps could be a bit shorter:

      ^.\K(([\w.,']+)\x20){3}[\w.,']+

      If not: The trick is, to deactivate ‘ordinals’ in the smallCaps cStyle and let small caps begin on the second character.

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