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

GREP Exclude characters

Engaged ,
Sep 17, 2018 Sep 17, 2018

Hello!

In my text the letter g means glossary. 

And I need DELETE all paragraph contains only numbers.  I mean, I need keep the paragraph if contain the cross references like the letter g and (See...)

Here you can see in color PINK the paragraph I need delete.

Screen Shot 2018-09-17 at 12.43.34.png

here is my code, but I don't know how can I EXCLUDE the other paragraph.

replaceTextUsingGREP ("+(\\d[–\\d, -]*\\d?) *","\r");

function replaceTextUsingGREP (input, output) {

    app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

    app.findGrepPreferences.findWhat = input;

    app.changeGrepPreferences.changeTo = output;

    var changedResults = app.activeDocument.changeGrep();

    app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

}

Thanks so much!

TOPICS
Scripting
3.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

correct answers 1 Correct answer

Guide , Sep 17, 2018 Sep 17, 2018

Hi Manuel,

I would suggest you use a negative lookahead to filter those "g" and "(See…" patterns.

For example:

replaceTextUsingGREP("^(?!.+ (g|\\(See [^)]+\\)),? \\d).+ \\d[\\d, -]*\\r", "");

// ...

The pattern /^(?!.+ (g|\(See [^)]+\)),? \d).+ \d[\d, -]*\r/ can be thought as follows:

GREP-Explained.png

@+

Marc

Translate
Guide ,
Sep 17, 2018 Sep 17, 2018

Hi Manuel,

I would suggest you use a negative lookahead to filter those "g" and "(See…" patterns.

For example:

replaceTextUsingGREP("^(?!.+ (g|\\(See [^)]+\\)),? \\d).+ \\d[\\d, -]*\\r", "");

// ...

The pattern /^(?!.+ (g|\(See [^)]+\)),? \d).+ \d[\d, -]*\r/ can be thought as follows:

GREP-Explained.png

@+

Marc

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
Engaged ,
Sep 17, 2018 Sep 17, 2018
LATEST

Hi Marc,

very kindness, for the explanation.

Thanks so much are working fantastic!

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