Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


GREP style to catch all hyphenated words

Community Beginner ,
Sep 12, 2019 Sep 12, 2019

Copy link to clipboard

Copied

I currently use a GREP style, "\w-\w" to catch all hyphenated words such as "4-year" or "end-to-end" but I'm not entirely confident as to how robust it is and where it might fail and catch something unintended. What winds up happening is InDesign catches 4-y" or "d-to-d" and applies my no break style to the text. While this seems to be working fine, I'm about to apply this to a MUCH longer document and I want to make sure I'm not going to encounter any unforeseen issues because this seems too expansive a search for GREP to work with. Does anyone have a snippet they use all the time to handle this sort of thing?

Views

573

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 12, 2019 Sep 12, 2019

Copy link to clipboard

Copied

Why not test your text with a GREP search first? If that seems fool-proof, allow it to become a GREP style.

Mike Witherell

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2019 Sep 12, 2019

Copy link to clipboard

Copied

Two reasons. First, I'd love to have a fool-proof go to GREP style to work with whenever I needed it. While it may work on this document, it mat have problem in with future ones and I;d have to retest each time I implemented the style. Second, this is a very long document with a lot of hyphenated footnote markers. It will take tie to go through each instance of the hyphenated words that I'd rather avoid. I was hoping someone may have solved this already and has a snippet they would be willing to share.. I'm trying to learn to use GREP more and more but sometimes I run across something that alludes my limited skills.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 12, 2019 Sep 12, 2019

Copy link to clipboard

Copied

Why a no-break over hyphens? There is a non-breaking hyphen for that.

You can use GREP to find-and-replace: search for "(?<=\w)-(?=\w)" and replace with .. uh, the GREP code for a non-breaking hyphen. (Look in the "@' dropdown menu.)

The advantage is that if it gets applied to something unexpected, you can simply replace that instance with a regular hyphen.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2019 Sep 12, 2019

Copy link to clipboard

Copied

See above. I would prefer this to be a GREP style I can easily reuse without having to intervene every time the document gets updated or changes are made. This seems to be something well within the wheelhouse of GREP but I'm just a little concerned that my initial attempt ay be too inclusive.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

Did you ever get confirmation about this? I use the same style but after Googling there seems to be a lot of more complicated GREP styles which makes me wonder if my simple style is not adequate.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

LATEST

Why not just apply the GREP style and see what happens? You can use Find/Change to search for the character style and see where it is applied. You can also alter the style to include a highlight colour to make instances easier to spot.

 

See, even if someone gives you the answer you are looking for, I hope you would check to see that it accoomplished what you want. How do you plan to do that without checking the entire document?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines