Copy link to clipboard
Copied
Is there a limit on how long the found GREP result can be??
For shorter blocks of text - it will select all lines:
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??
Nor this:
<Title renamed by MOD>
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:
or:
So there is no limit on the length?
Copy link to clipboard
Copied
After deleting space before "http":
"." means "any character", right??
And change to ".+" from ".*" - finds even less??
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?
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?
And I've just fond something else - it completely skips this and few other:
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:
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.
Copy link to clipboard
Copied
Sorry, that should be
(?s)REFERENCES\r\K.+?(?=CHAPTER)
(add a question mark after .+)
Copy link to clipboard
Copied
Thanks.
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:
I've copied missing block to a Notepad to clear all formatting and junk - didn't help, still skipping it.
Copy link to clipboard
Copied
Can you show the context of 'there'?
Copy link to clipboard
Copied
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:
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?!?!
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...
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)
Copy link to clipboard
Copied
Thanks @Peter Kahrel - but there are no Footnote markers in this block of text.
Copy link to clipboard
Copied
I have experienced the same problems. There is definitely a bug with long grep searches in InDesign.
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.
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.
Copy link to clipboard
Copied
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.
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.
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.
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.
By @Peter Kahrel
Even if I go through the Notepad - doesn't help.