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

GREP for finding a "sentence"

Community Expert ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

Hi all,

 

Trying to dissect NestedStyles (1st paragraph is done as Text Style Ranges) - got everything else but I'm stuck on the "Sentence".

RobertTkaczyk_3-1688851538396.png

 

Found this somewhere - ".+[.!?'"]+"

 

But InDesign is including also the Space - because of the "through" - how should I modify the above - or is there a better way ?

 

TIA

TOPICS
Scripting

Views

363
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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

Hi Robert,

what exactly do you want to find?
Because what you have marked is not a sentence by definition.

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

Hi @Robert at ID-Tasker, first you must define a sentence in rigorous terms (as you did with the regex). You can google to see various definitions. Then you can pick one that suits your needs. Each definition will have trade-offs, because sentences are difficult to delineate in some cases. If you have sample data, then perhaps you can derive a sentence definition from that—by ensuring that the definition selects all sentences in the sample data.

- Mark

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

Thanks @pixxxelschubser and @m1b for a quick replies.

 

My goal is to show structure of the text - based on the Nested Styles applied to the Paragraph - so the "sentence" will be anything that ends with ".", "!", "?", right? And maybe """, "'"? 

 

What I'm using right now is almost working - but like I've said - InDesign is also including a space after the ".". 

 

So, in general, I'm looking for InDesign's definition of a "sentence".

 

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

Here is an example nested style that seems to work (it doesn't select the space):

Screenshot 2023-07-09 at 09.37.22.png

Is what you are trying to reproduce? It's not clear what you've tried already and what feature you want to use. Maybe you want to use a grep style? Or are you scripting? It always helps to show a very simple and clear example.

- Mark

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

Up to ignores the space - but "through" will include it. 

 

And I want to do it though GREP - on the text - to find what InDesign is finding - with NestedStyles - kind of simulate it myself.

 

Going through Text Style Ranges is piece of cake - 1st paragraph in my example screenshots. 

 

All other NestedStyles breakpoints are not a problem - only the "sentence" is a problem - hot to include all "white spaces" after the end of the "sentence" - the same way as InDesign is doing. 

 

By the way - two of them are in scripting - but no longer in the UI - DropCap and one more - can confirm tomorrow. 

 

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

This might be a start?

Screenshot 2023-07-09 at 10.38.00.png

 

It still doesn't match every case. Looks like it will be a comlicated grep to achieve parity. Good luck.

- Mark

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

LATEST

Thanks @m1b

 

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

That comes second.
I completely agree with @m1b . That is exactly the crux of the matter.

 

First of all, this has to be clarified:

Because sentences like the following are difficult to grasp with Grep.
Prof. Dr. Smith organised a competition. 21,278 people took part. "Nothing is impossible" - that was his motto.

 

--> How are your sentences structured? What exceptions should be considered?

Votes

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 ,
Jul 08, 2023 Jul 08, 2023

Copy link to clipboard

Copied

What I'm trying to achieve is recreating NestedStyles functionality. 

 

I want to find "sentence" from the current cursor position - or rather end of previous NestedStyle occurrence.

 

Votes

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