Positive Lookbehind/Lookahead. This GREP expression
does the trick. I've coloured the different parts: red is the lookbehind, green is the lookahead, black is regular text.
In essence, it finds (selects) any capital K which is preceded and succeeded by parentheses. Replace with what you like -- the parentheses are not touched.
It's useful to know there is also a negative lookbehind/lookahead. The expression
will find any capital K except those surrounded by parentheses.
Thank you for your reply. I must be missing some small detail because the results that I'm getting after using the GREP Find/Change are that the (K) is replaced with (? ()K(? )) in the text, so it is not working.
In Find What is \(K\)
In Change To is (?<=\()K(?=\))
and in Change Format I have the Font that I need to use.
What am I doing wrong?
A minor detail, I hope. I left out that the Lookbehind/Lookahead functions are search functions, not replace.
Put the find text in the GREP Find text field, not in the regular Find. Then, make sure the Change To field is empty -- drag your mouse over it, and if you see something selected, hit Delete. Only because you put something into the Change Format, InDesign knows it shouldn't replace the text with nothing, but apply the formatting instead.
It should look like this:
Thanks for replying so quickly -- Yes, this works perfectly! Wonderful! Now I've added it to the paragraph style so that it works automatically.
Yeah, I also really like the GREP styles. Any reason to use them is appreciated!