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

Issues with GREP Selecting Long Text Blocks in InDesign

Community Expert ,
Oct 31, 2024 Oct 31, 2024

Copy link to clipboard

Copied

Is there a limit on how long the found GREP result can be??

 

RobertatIDTasker_0-1730405543397.png

 

For shorter blocks of text - it will select all lines:

 

RobertatIDTasker_1-1730405603237.png

 

If I start removing some words from the first block - it will select bigger part - more paragraph(s)??

 

Also, what should be the GREP query to find everything in between:

 

REFERENCES

...

...

CHAPTER

 

but excluding those words - so the found result will be like on the 2nd screenshot.

 

Because, even something like this doesn't work??

 

RobertatIDTasker_2-1730405780620.png

 

Nor this:

 

RobertatIDTasker_3-1730405920803.png

 

 

 

<Title renamed by MOD>

 

TOPICS
Bug

Views

457

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 ,
Oct 31, 2024 Oct 31, 2024

Copy link to clipboard

Copied

I've copied whole text into a Notepad - to strip all formatting - and now, it can select few pages of text:

 

RobertatIDTasker_1-1730406662999.png

 

or:

 

RobertatIDTasker_0-1730406638965.png

 

So there is no limit on the length?

 

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 ,
Oct 31, 2024 Oct 31, 2024

Copy link to clipboard

Copied

quote

RobertatIDTasker_0-1730406638965.png

 

After deleting space before "http":

RobertatIDTasker_0-1730406980253.png

 

"." means "any character", right??

 

And change to ".+" from ".*" - finds even less??

 

RobertatIDTasker_1-1730407075057.png

 

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 ,
Oct 31, 2024 Oct 31, 2024

Copy link to clipboard

Copied

To match everything between those two words, do this:

 

(?s)REFERENCES\r\K.+(?=CHAPTER)

 

The default is that the dot doesn't match paragraph breaks. That can be overruled by (?s).

 

As for the amount of text that can be matched, there was a restriction a few versions ago of 32K characters. What is the limit in your tests?

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 ,
Oct 31, 2024 Oct 31, 2024

Copy link to clipboard

Copied

Thanks @Peter Kahrel.

 

Unfortunately, it doesn't work all the time...

 

For some reason, there is one place where more is selected than should be?

 

RobertatIDTasker_0-1730409244030.png

 

And I've just fond something else - it completely skips this and few other: 

 

RobertatIDTasker_1-1730409407990.png

 

Also, there can be ":" after "REFERENCES" - of course I don't count those as skipped.

 

There are also Tables in between, so it looks like I'll have to implement it - finding & formatting block of text - differently in my IDT - which isn't a big deal, but I was hoping blocks can be found using GREP.

 

I can always do two searches:

 

RobertatIDTasker_2-1730409985478.png

 

and then process results by going through the list, selecting Paragraph after checked line and up to next visible and unchecked line - and ItemByRange().

 

Or make it even more universal - I'll select from-to and then unselect 1st and last Paragraphs of the selection.

 

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 01, 2024 Nov 01, 2024

Copy link to clipboard

Copied

Sorry, that should be

 

(?s)REFERENCES\r\K.+?(?=CHAPTER)

 

(add a question mark after .+)

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 01, 2024 Nov 01, 2024

Copy link to clipboard

Copied

@Peter Kahrel 

 

Thanks.

 

RobertatIDTasker_0-1730503523737.png

 

Much better, after I've removed extra space in one place and ":" in another - found almost all - but still skips one block - and I don't see anything wrong there:

 

RobertatIDTasker_2-1730503936169.png

 

I've copied missing block to a Notepad to clear all formatting and junk - didn't help, still skipping it.

 

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 01, 2024 Nov 01, 2024

Copy link to clipboard

Copied

Can you show the context of 'there'?

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 01, 2024 Nov 01, 2024

Copy link to clipboard

Copied

quote

Can you show the context of 'there'?


By @Peter Kahrel

 

I just played a bit with it - by removing some paragrpahs - from the start of the block and the end of the block:

RobertatIDTasker_0-1730506173673.png

 

The top 4x paragraphs - there is more on the previous page - if they are there - this whole block won't be found...

 

BUT - if I'll remove ANY of them - 1st or 2nd or 3rd or 4th - but only one - this block will be found?!?!

 

So it's not like any specific paragraph affects the result - removing ANY ONE will find the block?!?!

 

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 01, 2024 Nov 01, 2024

Copy link to clipboard

Copied

Something is really wrong with GREP in InDesign...

 

I've spend last 20 minutes playing with it - and after I trimed it down a bit - removed few Paragraphs from the end of the block - then I can remove ANY additional paragraph - and whole block will be found by GREP?!?!

 

If I hit Ctrl+Z / Undo - block not found, remove ANY other random Paragraph - block will be found...

 

 

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 02, 2024 Nov 02, 2024

Copy link to clipboard

Copied

I now remember that there is indeed a bug in inDesign's grep engine: the dot doesn't match the footnote marker. To get around that, use this one:

 

(?s)REFERENCES\r\K(~F|.)+?(?=CHAPTER)

 

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 02, 2024 Nov 02, 2024

Copy link to clipboard

Copied

Thanks @Peter Kahrel - but there are no Footnote markers in this block of text.

 

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
Participant ,
Nov 02, 2024 Nov 02, 2024

Copy link to clipboard

Copied

I have experienced the same problems. There is definitely a bug with long grep searches in InDesign.

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 03, 2024 Nov 03, 2024

Copy link to clipboard

Copied

A simple experiment shows that a Grep search matches at most 20,000 characters. This restriction appeared a few years ago and was fixed, and now it's back apparently.

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
Participant ,
Nov 03, 2024 Nov 03, 2024

Copy link to clipboard

Copied

Long grep search has been broken in several versions of InDesign since that time it was fixed. Really frustrating as it is an extremely useful way to format features in book text.

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 03, 2024 Nov 03, 2024

Copy link to clipboard

Copied

@Marie_D

 

My solution will always work. 

 

Do you work on a Mac or PC? 

 

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 03, 2024 Nov 03, 2024

Copy link to clipboard

Copied

quote

A simple experiment shows that a Grep search matches at most 20,000 characters. This restriction appeared a few years ago and was fixed, and now it's back apparently.


By @Peter Kahrel

 

The block in question is way shorter. 

 

At one point I even suspected "opening single quote" in the middle of the last paragraph in the block - but after reloading document - it wasn't a problem. 

 

So something is really wonky with the GREP. 

 

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 03, 2024 Nov 03, 2024

Copy link to clipboard

Copied

The block in question is way shorter. 

 

There could be all kinds of hidden characters (discr line-breaks, text anchors). They all count as characters.

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 03, 2024 Nov 03, 2024

Copy link to clipboard

Copied

LATEST
quote

The block in question is way shorter. 

 

There could be all kinds of hidden characters (discr line-breaks, text anchors). They all count as characters.


By @Peter Kahrel

 

Even if I go through the Notepad - doesn't help. 

 

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