• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP styles doesn't apply, but GREP search works fine

Community Beginner ,
Nov 21, 2016 Nov 21, 2016

Copy link to clipboard

Copied

I'm using this GREP expression to fix widows and orphans: [^ ]{1,10}[[:space:]]*$

Problem is, when I create a GREP style in the paragraph style, it doesn't do anything. But if I do a GREP search and replace, it works as intended, so the code is not the issue.

Anyone know how to fix this?

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Hi

I suppose you've first created a character style, set as "non breaking":

nobreak.jpg

Did you start your GREP expression with a space? If yes, it should work.

If not, don't forget to insert a space at first, or \s

grep2.jpg

Regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

I did both, included a space at the beginning and use non break character style. It did not work.

Again, the code itself is not the problem, because when I did a search an replace, it worked as intended. Only when I create a GREP style within the existing paragraph styles did it not work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Well, it works fine for me

Maybe some screenshots might help.

What INDD version do you use?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

I'm using ID cc2015 on windows 10. And here are some screen shots

The code is supposed to hunt for every word that has its own line, and replace the space before it with a non-breaking space so that at the end of each paragraph, there will be at least 2 words in a line:

11312161_698078700337453_16606530_n_1_jpg_jpg.png

I have the grep like so (note: the character style is Hyperlink because it's easier to notice changes)

11312161_698078700337453_16606530_n_1_jpg_jpg.png

But the damn thing, for some reason, only change the character style of the LAST 2 PARAGRAPHS, which doesn't even have orphans!

11312161_698078700337453_16606530_n_1_jpg_jpg.png

GREP search, on the other hand, have no problem identify the stand alone words and insert non-breaking space in front of them.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Hi again,

OK I understand better...

Your GREP query looks for the last word of every paragraph - including space before - up to ten characters (why not more?): this might explain why it doesn't catch the last word of the other paragraphs (more than 10 characters maybe?)

So, why would it not "catch" the last words as seen of screenshot ? Of course it would, and it's not a problem, if the applied character style have only one setup, which is "NO BREAK"...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

The first image I shown have a 4-character orphan. The one precedes it also has 4 characters. Including the space between them, there're 9 characters in total, and yet they completely flew under the radar.

Also, the grep search have no issue identify those two, and brought the 2nd-to-last word down to the last line of the paragraph. This is so confusing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Hi again

sorry I missed the first screenshot showing the problem.

Hmmmm, it sure is tricky. I don't have any more ideas really.

Except maybe trying another GREP query, like (\H+?\h?){2}$

I wish I could have a look into your file, but I use CS6.

Maybe a GREP specialist (I'm NOT!) might help you there.

regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

LATEST

> The code is supposed to hunt for every word that has its own line,

No, you code looks for the last string of non-space characters up to 10 characters long.

> and replace the space before it with a non-breaking space so that at the end of each paragraph,

> there will be at least 2 words in a line:

You can't do replacements in GREP styles. You could apply a character style (with no-break set) to the space before the last word.

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Wouldn't keep options more suitable for dealing with widows and orphans ?

Apart from that, you may try this:

(?<=.)\s*$

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

If you make your applied character style highly visible, can you see if it does anything at all? See this, for example. It uses your original GREP style - and appears to be working correctly.

lorem.PNG

What OS and what version of ID are you using? It may be version-dependent (though it sounds like it should not be).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Jongware, I think GREP should "catch" the space before, otherwise it sure won't produce any effect...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Well yeah, sure. I based my "it is working" on OP's statement that the GREP itself does not work. It does.

Whether or not it does do what OP wants it to is something else.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines