GREP: finding double hyphenated words

Learn / Forums / General InDesign Topics / GREP: finding double hyphenated words

Viewing 2 reply threads
  • Author
    Posts
    • #53924

      I'd like to find a way to search for words that are hyphenated that InDesign hyphenates at the end of a line of justified text. An example would be “double-longterm” (it's not a word but it's just an example). If this appears at the end of a line the program might hyphenate it as “double-long-term”. I can't seem to find a way to find the second hyphen that InDesign puts in when it breaks a word. Any ideas?

      I can't have double hyphenated words in some of the books I do and I always manage to miss a few of these.

      John

    • #53925

      You cannot search the hyphen InDesign adds itself. I would suggest a tiny javascript instead. (Beware! Untested! Your Computer May Explode (etc.))

      app.findGrepPreferences = null;

      app.findGrepPreferences.findWhat = “bw+-w+b”;

      result = app.activeDocument.findGrep();

      if (result.length == 0)

      alert (“No More! No More!”);

      else

      result[0].select();

      Then fix them yourself.

      —-< Afterthought, 2 seconds later >—

      Ahhhh — perhaps it's easier to apply No Break to the individual parts of the word (but not the hyphen!). You would need two GREP styles for that, one for each half:

      <w+(?=-w)

      and

      (?<=w-)w+>

      — both should apply a character style containing No Break. You might want to consider checking a maximum length of the word parts. There are not that many ten-letter-each compound words, but surely you would consider hyphenating “representative-elect”, “three-dimensionalness” or “vice-chancellorship”? (14 letters and more before or after the hyphen; just a few random finds in my English word list)

    • #54090
      keithk
      Member

      Not claiming to be an expert on (any of) this, and the previous post may be saying the same thing in different words: Having disclaimed that :-) you could use something like BBEdit to grep search hyphenated words and insert the “no break” tags in a text file before importing it in the first place. Also, the InDesignConverter software from editorium.com converts Word docs to tagged text and one of the options is break hyphenated words only at the hyphen. Don't know what your workflow is, but that might be worth a look.

      and yeah, I'm getting the math-captchas on every post

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
>