Copy link to clipboard
Copied
Hi,
What I'm trying to do with GREP is to match only the last two Chinese characters (or Kanji according to the official doc) in paragraphs, regardless of punctuation marks and alnums.
Here's the expression I've tested:
~K[[:punct:]]*~K[[:punct:]]*$
This didn't work. However, when I replace "~K" with "\w" , it works, which means alnums are matched.
Is there something special about "~K"? Or is there a way for my need?
Thanks,
Yuwen
Copy link to clipboard
Copied
Hi Yuwen,
did you find an answer to your question?
If yes, what was the solution?
If not, can you provide a sample document? Just one page with one text frame where we could do some tests.
Please, put it on Dropbox or a similar service and post the download link.
Thanks,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thanks for reply Laubender.
I've attached a sample with placeholder text below. You can just try
~K[[:punct:]]*~K[[:punct:]]*
and
\w[[:punct:]]*\w[[:punct:]]*
They should be exactly the same when there is no alnum. However the former cannot match anything. I believe it's the "~K", but don't know why.
Copy link to clipboard
Copied
Not ~K but \K
(^/) The Jedi
Copy link to clipboard
Copied
No. It's really ~K for Kanji.
Look it up in the documentation for metacharacters:
https://helpx.adobe.com/indesign/using/find-change.html
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Oups! =D
Could you post a .idml file?
(^/)
Copy link to clipboard
Copied
An InDesign CC 2019 document is attached in the first answer of the OP above.
Right after my first reply.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
It's an ID CC 2021!
(^/)
Copy link to clipboard
Copied
?? No. Obviously not.
Just opened the test document in my German InDesign version 14 on Windows 10.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Oups 2!
Not the good doc! =D It was about yours in another thread:
TableWithContinuedHeaderRow-2021.indd
Could you post it saved in .idml! 😉
(^/)
Copy link to clipboard
Copied
No need!
(^/)
Copy link to clipboard
Copied
Hi Yuwen,
using ~K alone is working very well. Just tested this with your document that I opened in InDesign 2021.
Also ~K{2}$ is doing its job. Last two Kanji glyphs ( characters ) at the end of a paragraph.
Could you mark in a screenshot of your sample document what you like to find?
I can only detect one single paragraph in that text frame.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
If I'm adding a paragraph sign after a sentence the following expression will find the last two Kanji glyphs before the punctuation at the end of a paragraph:
~K{2}(?=[[:punct:]]*?$)
Don't know if that will meet your needs…
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
About the original question!
Weird Grep behavior! …
Try this:
(~K)[[:punct:]]*(?1)[[:punct:]]*$
(^/)