Copy link to clipboard
Copied
I have a paragraph that asks several questions. After the last question I want the GREP style to apply to give the answer to the questions a different color to get this result.
"Where was it? When did it happen? At the market at 5:00 p.m."
This below works for finding the question mark, but the problem is that it finds every single one.
(?<=\?).+
Giving me this problem.
"Where was it? When did it happen? At the market at 5:00 p.m."
Is it possible to find only the last occorance of the question mark?
Thanks!
It's not a very "elegant" solution - and I'm pretty sure someone will find a better one - but maybe it be will good enough for you:
You can always add extra inclusions.
Works for me in 2025 and in 2023
Have to admit it didn't work when I copied it from the forum that's for sure.
It did actually work - something didn't copy right first time - but it does work for me now - oddity with the forum maybe.
(?<=\?(?!.*\?)).+?.+(?=")
It's much more simple:
[^?]+$
In other words, 'not-question mark to the end of the paragraph'.
I hadn't spotted that the closing " should be excluded. Itt should be like this:
[^?]+(?="$)
which also fixes the problem of selecting lines that don't contain any question marks.
Copy link to clipboard
Copied
I'm replying from my phone so can't check right now:
\?.+$
"$" represents end of paragraph.
But it will also style "?" so you still need to play with those look ahead / behind.
I hope it will at least get you on the right track.
Copy link to clipboard
Copied
Or maybe this will work?
\?\K.+$
But InDesign's GREP is greedy - so you might still need to add extra "?" somewhere...
As I've said, I'm on my phone so just brainstorming.
Copy link to clipboard
Copied
It's not a very "elegant" solution - and I'm pretty sure someone will find a better one - but maybe it be will good enough for you:
You can always add extra inclusions.
Copy link to clipboard
Copied
Thank you! Seems very close. What do the brackets do?
Copy link to clipboard
Copied
Thank you! Seems very close. What do the brackets do?
By @Micah5C08
You're welcome.
Square ones - "any character from the list".
\w - any word character
\d - any digit
\s - any white space
\. - "."
\: - ":"
Copy link to clipboard
Copied
Ah perfect! Any new symbol I need in the colored answer part I can just add into the brackets! Amazing!
Thank you so much!
Copy link to clipboard
Copied
Ah perfect! Any new symbol I need in the colored answer part I can just add into the brackets! Amazing!
Thank you so much!
By @Micah5C08
Exactly 🙂
You're welcome.
Copy link to clipboard
Copied
I've just sent you a private message - could you please check top-right corner of this website.
Copy link to clipboard
Copied
(?<=\?(?!.*\?)).+?.+(?=")
Copy link to clipboard
Copied
(?<=\?(?!.*\?)).+?.+(?=")
Unfortunately, it doesn't work?
Copy link to clipboard
Copied
Works for me in 2025 and in 2023
Have to admit it didn't work when I copied it from the forum that's for sure.
It did actually work - something didn't copy right first time - but it does work for me now - oddity with the forum maybe.
(?<=\?(?!.*\?)).+?.+(?=")
Copy link to clipboard
Copied
I've typed it manually - not copy&pasted - unfortunately, still doesn't work:
Copy link to clipboard
Copied
Don't know why you can't get it to work - it works.
Copy link to clipboard
Copied
It's much more simple:
[^?]+$
In other words, 'not-question mark to the end of the paragraph'.
Copy link to clipboard
Copied
It's much more simple:
[^?]+$
In other words, 'not-question mark to the end of the paragraph'.
By @Peter Kahrel
You are Genius 😄
I was playing with exclusion - but I was using "!" instead of "^" 😞
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I hadn't spotted that the closing " should be excluded. Itt should be like this:
[^?]+(?="$)
which also fixes the problem of selecting lines that don't contain any question marks.
Copy link to clipboard
Copied
I hadn't spotted that the closing " should be excluded. [...]
By @Peter Kahrel
There are no closing - nor opening - (").
OP used them to show/mark quoted text.
Copy link to clipboard
Copied
We don't know that - it could be enclosed in quotes.
That's the sample text provided - that's what I was using to find the text.
Copy link to clipboard
Copied
I guess why it's not working for us - using different sample text...
I guess the OP has many ways and options now.
We all get a cookie.
Copy link to clipboard
Copied
Ah yes - that's great - I might be overthinking it as usual - perhaps the quotes are not part of the search at all.
Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now