InDesign GREP style ignoring last word

I’m formatting a music program that mixes English and Chinese. I read a tip that suggested using the Chinese font in the style definition and then using a “GREP style” for switching to an English font (and rules) over characters in the range of those characters.

Great idea!

Note that I already am adept with regular expressions in Perl 5, and I’m also knowledgeable about Unicode including how it’s organized.

Everything I find via Google on InDesign GREP Style is a basic tutorial about regular expression and dead simple to anyone who already knows Perl etc. I’ve not seen anything about how InDesign 11.1.0.122 on Windows is using the regexp, which I assume is some particular way

enter image description here

Note that the expression stops at the last space in the paragraph, and is not applied to the last word. A work-around is to add extra space at the end, but that’s wrong for centered text.

The expression /[$a-$b]+/ when $a and $b include all ASCII characters will not stop at a space, and even if it did (e.g. some other kind of whitespace character), the stuff after it would be consecutive letters in that range, too.

So what exactly is InDesign doing with the expression, and more to the point why does it not work as stated?

(Once I get it working at all, I can improve upon it if InDesign knows the codes for Unicode properties, rather than stating a range of absolute code point values.)

Answer

It turns out I had an unseen trailing space in the field. Maybe you can tell in the blue highlight in the illustration once you know to look for it. I had

[\x{0020}-\x{2fff}]+ 

rather than

[\x{0020}-\x{2fff}]+

due to extra space being present from the copy/paste of the string.

Don’t see any difference above? Highlight it to show where the string actually ends. ☺

Attribution
Source : Link , Question Author : JDługosz , Answer Author : JDługosz

Leave a Comment