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 style for finding words at the end of a line

Return to Member Forum

  • Author
    Posts
    • #65508
      Cindy Kelley
      Participant

      Hi,

      I have an anal client who hates hyphenation and a line of text that ends with words such as “and”, “but”, “or” or any word smaller than four letters. I know, I know, this is going to make for some ugly paragraphs but this is what he wants.

      Can I use grep styles to fix these things in a similar way I use a grep style to fix widows?

      Thanks everyone!

      Cindy in Indy

    • #65510
      Cindy Kelley
      Participant

      I think I came up with a solution — I have replaced all the spaces following these words with a non-breaking space.

      If someone has a better idea or can make me a script to do this that I can use when I have this client’s jobs, I will send virtual hugs your way.

    • #65747

      Hi,
      I’m on the side of your client! Here’s a simple grep…

      Create a char style ‘no break’ – select only ‘No Break’ on the Basic Char Formats tab.

      Edit GREP Style for your chosen para style
      Add New GREP Style, with ‘no break’ char style selected, To Text: and (?=\w+)
      [space][the word][space][before one or more words]

      Instead of space, you could also put for ‘any space character’ instead of just typing [space].

      You’d need to make a style for each small word you want to apply ‘no break’ to…

      Too many GREPs slow down long documents, so it may not be viable for all projects.

    • #65749

      Just noticed that you don’t need the + in the grep – one word look ahead is enough.

    • #65797
      Matt Mayerchak
      Participant

      In a regular GREP, you can combine words as an OR expression with the vertical bar. So, for example, you could use just one GREP style for [and|but|or|for]. I have not tested this but it seems like it ought to work in this case.

    • #72051
      Gavin Anderson
      Participant

      Here is a GREP for getting rid of orphans.

      Apply a NO Break character style (a style where the only thing specified is that No Break is forced on) to the following:

      (\w+ \w+)[[:punct:]]$

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
Forum Ads