Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Indesign - Grep Style return after a comma

New Here ,
Jul 15, 2019 Jul 15, 2019

Hi All,

I have a question that I am unable to find the answer.

I have an address that is followed by comma after each road name, place and postcode. I would like to have an automated process where the GREP Style will place a soft return or hard return after each comma, regardless if it has more room within the bounding box or not. The reason why I don't want to just place a soft/hard return myself is because the information is driven by a data merge, this information change change drastically depending on the how long the address is.

Please see attached example below.

From:

Screen Shot 2019-07-15 at 16.00.21.png

To:

Screen Shot 2019-07-15 at 16.00.40.png

Thank you,

Scott.

1.8K
Translate
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 Expert ,
Jul 15, 2019 Jul 15, 2019

GREP Styles can only add styling to text -- you cannot add or remove text with them. You would have to use a GREP search (Find & Change) for this.

Translate
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
Participant ,
Jul 15, 2019 Jul 15, 2019

    var myDoc = app.documents[0];

    app.findGrepPreferences = NothingEnum.nothing; // Suchfeld leeren   

    app.changeGrepPreferences = NothingEnum.nothing; // Ersetzen-Feld leeren   

    app.findChangeGrepOptions.includeFootnotes = true;   

    app.findChangeGrepOptions.includeHiddenLayers = false;   

    app.findChangeGrepOptions.includeLockedLayersForFind = false;   

    app.findChangeGrepOptions.includeLockedStoriesForFind = false;   

    app.findChangeGrepOptions.includeMasterPages = false;   

    /*app.findGrepPreferences.appliedParagraphStyle =pStylename;  //P style name*/

    app.findGrepPreferences.findWhat = "\\,\\s";   

    app.changeGrepPreferences.changeTo = ",\\r"; 

    myDoc.changeGrep();

    app.findGrepPreferences = NothingEnum.nothing; // Suchfeld leeren   

    app.changeGrepPreferences = NothingEnum.nothing;

Translate
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 Expert ,
Jul 15, 2019 Jul 15, 2019
LATEST

SJRiegel​ is correct, GREP styles cannot change the spaces to either a soft or a hard return. But this might work – emphasis on the "might" because it is, quite literally, quite a stretch.

The character style "no-break" only sets No Break. This is necessary because otherwise InDesign will try to break between all of the words, rather than just on the spaces after the comma.

The character style "wiiiideeeeee" sets 1000% Horizontal Scale and Tracking: +1000.

Here comes the trick: you cannot see it in this screenshot (and I'm about to go home for today so I won't shoot it again), but after the top "To Text: (?<=,)" there is a single space at the end. And that is the space that you see in the screenshot at the right, all stretched out.

(It won't work if your frame is so wide that even the thousands' of scaling and tracking does not suffice.)

Translate
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