35 Replies Latest reply on Oct 1, 2016 9:23 PM by Shlomit Heymann

    How do I use GREP expression to keep the last two words of a paragraph together?

    vkhu123 Level 1

      Hi guys, I'm dealing with a document that's riddled with orphan, and want to use GREP to get rid of them all.

       

      I found this thread talking about how to keep all last 10 characters together. But in my language, you can have up to 4 words together (nearly a third of the sentence!) and still not break the 10-character limit. So if I use that expression, some sentence will get cut off midway, which make the whole paragraph looks horrendous. I also tried the (\s\w+.?)$ expression, but it left some orphans untouched (very random, no pattern at all).

       

      So is there any expression that can make the last 2 words of any paragraph stick together like glue?