Skip to main content
Inspiring
February 19, 2019
Answered

Grep expression to change font of Hebrew characters only

  • February 19, 2019
  • 3 replies
  • 5546 views

Due to the discussion in the thread here: https://forums.adobe.com/thread/2596476

I was wondering if there is a Grep expression that could be used to apply a character style to Hebrew characters only (based on their position in the font map) to allow changing of the font of just those characters? I'm pretty good at find/replace but really don't know anything about using Grep. If Grep could do something like this it would save me a tremendous amount of time as I normally use English fonts that do not contain a Hebrew character set and need to apply a character style to each bit of Hebrew (which is interspersed within the English) to change it to a font with Hebrew characters.

I would think this might be possible with Grep. If anyone knows how, please let us know.

    This topic has been closed for replies.
    Correct answer winterm

    Like Chad, I don't know a single word (or even letter, for that matter) in Hebrew, but here's my exercise, just for fun. I went from the opposite: find all non-Latin text and punctuation/spaces after it. 3 regexes to include in para style:

    [^A-Za-z\h[:punct:]]+

    [^A-Za-z[:punct:]]\K\h

    [^A-Za-z]\K[[:punct:]]\h

    3 replies

    Inspiring
    February 21, 2019

    I use

    ‭[‬\x{05D0‭}-‬\x{05EA‭}‬\x{0591‭}-‬\x{05C4‭}‬\x{05A2‭}-‬\x{05C7‭}]+‬

    TᴀW
    Legend
    February 20, 2019

    I haven't read the entire thread, but from my extensive experience typesetting predominantly English books with interspersed Hebrew, the best way to apply a character style to the Hebrew is to search for all text that has its language set to Hebrew!

    The reason is that luckily enough most authors write in Word, and when the keyboard is switched, in Word, to Hebrew, Word is smart enough to mark that text as Hebrew language. And this comes through into InDesign, so 90% of the time all Hebrew is properly marked as being Hebrew in InDesign.

    Note, though, that for this to work you must first save an docx documents as the older .doc format in Word. The import filter in InDesign for .docx documents isn't as robust as the earlier .doc import filter, and only the older one imports language markings properly.

    Just my 2 cents...

    Ariel

    Cyndee MAuthor
    Inspiring
    February 20, 2019

    TᴀW  wrote

    I haven't read the entire thread, but from my extensive experience typesetting predominantly English books with interspersed Hebrew, the best way to apply a character style to the Hebrew is to search for all text that has its language set to Hebrew!

    ...

    Note, though, that for this to work you must first save an docx documents as the older .doc format in Word. The import filter in InDesign for .docx documents isn't as robust as the earlier .doc import filter, and only the older one imports language markings properly.

    I just tested this and you are correct, with one additional point. Even a .docx file retains the Hebrew style, IF you place the document with the "remove styles and formatting" option (which is my preference for the files I get for these jobs). If you place a .docx file and preserve or map styles, then the Hebrew style is not retained.

    This may be helpful in some situations, but when I have a .docx file and want to preserve or map styles, then winterm's method may be simpler as I don't need to go through the extra step of opening and resaving the Word file.

    I am sure that there will be some times though that I will prefer to use your method.

    TᴀW
    Legend
    February 20, 2019

    I always import with styles and formatting, and strip everything out afterwards in InDesign (after freezing any wanted formatting with character styles).

    The problem with a GREP search to find Hebrew strings is that it's impossible to sort out the issue of opening and closing punctuation, because only a human can know whether the opening or closing punctuation is meant to be Hebrew or not. So what happens in practice is that you have to go through each Hebrew phrase and check (or compare to original) which is a pain.

    But if you rely on the language setting, most times (if the author was half competent at inputting the original text) the issue of punctuation etc. will be mostly okay...

    In any case, I've never found a GREP expression that really worked for me.

    hammer0909
    Community Expert
    Community Expert
    February 19, 2019

    You should be able to. You'll need to have a paragraph style applied to the Hebrew text. Then within the paragraph style, you can apply a character style using a GREP style that would look something like below. My character style is just highlighting the characters. I can't read Hebrew so I have no idea what it says. Hopefully this helps though. Just create a GREP expression for each character you want to change.

    Cyndee MAuthor
    Inspiring
    February 19, 2019

    Thanks, but that would be kind of tedious to change 1 character at a time. Is there a way to use Grep to change a range of characters based on their ASCII number or position in the character map of the font? If possible, that would allow all of the characters that need to be in a Hebrew font to be changed at once. I think that what you've suggested could even be done with the regular find/replace dialog.

    winterm
    wintermCorrect answer
    Legend
    February 19, 2019

    Like Chad, I don't know a single word (or even letter, for that matter) in Hebrew, but here's my exercise, just for fun. I went from the opposite: find all non-Latin text and punctuation/spaces after it. 3 regexes to include in para style:

    [^A-Za-z\h[:punct:]]+

    [^A-Za-z[:punct:]]\K\h

    [^A-Za-z]\K[[:punct:]]\h