You probably forgot to escape the backslash. So instead of \r try \\r
Thanks for the response Peter, but no, I didn't.
I'm wondering if my problem is just because I'm looking for a certain Paragraph Style, rather than character style... Could that be the proble?? and, if so, how can I get over it?? I still need to search for the paragraph style....
A couple of observations:
You are using a lot of extra parentheses which are not necessary. It makes everything a bit more muddy than it already is ... For example, instead of
... or be followed by another note, in which case, the second note should not be included in the selection ..
Were you expecting the second (^Note:) to not include that text? Because it does -- (^...) is not a Negate function. If it did work, it would include "Note:" at the start of the next line, and since the previous character already is an "\r" the "^" is, at best, obsolete, and at worst, it may throw off GREP and thus work not at all.
Now, when I try the expression in the GREP Find/Change in InDesign it works fine ...
It doesn't -- not on a few paragraphs I tried it on, with and without "Note:" in front. It only finds the next entire paragraph starting with "Note:"
Can you give a sample text where it does work, and where it doesn't but should?
This appears to work:
-- it will find "Note:", followed by any number of next paragraphs in the same style that not start with "Note" again. Is this what you were after?
Thanks a lot for the answer, Jongware
To be honest, I have no idea as to why I used that many parentheses, but I did take your advice into account.
I simply can't make the script work properly...
It works from within a script as well for me. I tested with this text:
Note: dis is a note.
Dis is too.
Note: don’t pick up this one.
-- all in the same style. This script found, and changed, only the first two lines:
app.findGrepPreferences.findWhat = "^Note:.+(\\r(?!Note:).+)*"; app.findGrepPreferences.appliedParagraphStyle = "note style"; result = app.activeDocument.findGrep(); result.underline = true;
-- it found this:
-- and a Find Next, or changing the script to "result.underline = true;" correctly marks the second line as well.
So there must be something wrong elsewhere in your version.
An interesting variant of the above expression:
Given a text:
Note: this too.¶
this one will find the first "Note:" and its two following hard returns, after that the next "Note:". My previous GREP would only find the second note.
Ok, so I definitely was wrong.
I'm trying to modify a script so adjust it to my needs and, for some reason, it didn't work with your expression. I tried your piece of scritp, though, and decided to somehow restart the script.
I'll just have to overcome my scripting inutility.
Thanx a lot, nevertheless!