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

Grep deleting extra returns

Community Beginner ,
Oct 08, 2018 Oct 08, 2018

Copy link to clipboard

Copied

Hi,

I am trying to remove extra returns at the end of a story, but my script remove returns at the end of every paragraph.
How can I make it delete only extra returns at the end of a story?

function myFindGrepDelEmpty(myObject){
    app.findGrepPreferences = null;
    app.changeGrepPreferences = null;
    app.findGrepPreferences.properties = {findWhat:"^\\s+|\\s+$"};
    app.changeGrepPreferences.properties = {changeTo:""};
    app.findChangeGrepOptions.properties = {includeFootnotes:true, includeMasterPages:false, includeHiddenLayers:true, wholeWord:false};
    myObject.changeGrep();
}

TOPICS
Scripting

Views

431

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

correct answers 1 Correct answer

Guide , Oct 09, 2018 Oct 09, 2018

First:  ^\s+

Then:  \s\z

\z just means "end of story"!

Votes

Translate

Translate
Guide ,
Oct 09, 2018 Oct 09, 2018

Copy link to clipboard

Copied

\s+\z

Votes

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 ,
Oct 09, 2018 Oct 09, 2018

Copy link to clipboard

Copied

Michel,

thanks very much, that does the trick. But what does the "z" mean? It doesn't work in this combo: ^\s+|\s+\z.

Votes

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
Guide ,
Oct 09, 2018 Oct 09, 2018

Copy link to clipboard

Copied

First:  ^\s+

Then:  \s\z

\z just means "end of story"!

Votes

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 ,
Oct 09, 2018 Oct 09, 2018

Copy link to clipboard

Copied

LATEST

Thanks again, very helpful!

Votes

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