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

Add text frame below results of regexp

Explorer ,
Sep 06, 2016 Sep 06, 2016

Copy link to clipboard

Copied

I have a regexp that searches for 3 terms

(LEFT TRAVEL)

(RIGHT TRAVEL)

(BUCKET)

When it finds the terms it adds NOTE A to the textFrame it is found in.

Would it be possible to have NOTE A be Arial Bold without changing the other text in the frame?

And one more addition...would it be possible to create a new textFrame with NOTE A right below the position of the terms found?

Here is the current working code that adds the NOTE A to the text frame.

#target illustrator

var doc = app.activeDocument;

var allText = doc.textFrames;

// TEXT TO SEARCH FOR

var sensorSearch = /\(LEFT TRAVEL\)|\(RIGHT TRAVEL\)|\(BUCKET\)/gi;

// NOTE TO ADD

var addNoteA = "NOTE A", result;

// SEARCH AND CHANGE LOOP

   for (var i = 0; i < allText.length; i++) {

    // SKIP THESE BECAUSE THEY ARE IN THE COLOR TABLE

  if (allText.contents == "LEFT TRAVEL CONTROL CIRCUIT" || allText.contents == "RIGHT TRAVEL CONTROL CIRCUIT"){

  // SKIP THESE BECAUSE THEY ARE IN THE COLOR TABLE

  }

  else{

                while (result = sensorSearch.exec(allText.contents)) {

                    try {

                        aCon = allText.characters[result.index];

  //alert(allText.position);

                        aCon.length = result[0].length;

                        aCon.contents = aCon.contents + "\r" + addNoteA;

                    } catch (e) {};

                }

  }

  }

Any help would be appreciated!

TOPICS
Scripting

Views

180

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
no replies

Have something to add?

Join the conversation
Adobe