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

How just change the first match in Grepchangeto

Community Beginner ,
Apr 23, 2017 Apr 23, 2017

Copy link to clipboard

Copied

Hi I wanna grep just first the first match not all of them here the example:

text:

PP111111

PP222222

PP333333

and here the code

app.findGrepPreferences.findWhat = "^PP[0-9]{6,6}?$";

app.changeGrepPreferences.changeTo = "something";

then I wanna text change to this:

something

PP222222

PP333333

how Can I do this?

TOPICS
Scripting

Views

259

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

Community Expert , Apr 23, 2017 Apr 23, 2017

Hi,

Try below code.

app.findGrepPreferences.findWhat = "^PP\\d{6}?$";

var findTarget = app.activeDocument.findGrep();

findTarget[0].contents = "something";

Votes

Translate

Translate
Community Expert ,
Apr 23, 2017 Apr 23, 2017

Copy link to clipboard

Copied

LATEST

Hi,

Try below code.

app.findGrepPreferences.findWhat = "^PP\\d{6}?$";

var findTarget = app.activeDocument.findGrep();

findTarget[0].contents = "something";

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