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

looking for specific text inside a textFrame

Engaged ,
Jun 24, 2015 Jun 24, 2015

I am not sure how to utilize the index method of the textFrames collection.

I am trying to search through all of my text frames to see if it contains:    "SW"

If it does contain "SW" I want to have it remove "SW" from it's current location in the textFrame and put this at the beginning of the textFrame:    "Switch - "

Here is an example of a textFrame:     PARK_BRAKE_SW

Here is an example of a textFrame after the script would run:   SWITCH - PARK_BRAKE

Could also look like this:   SW_DISCONNECT_c0

Which after the script would look like this:   SWITCH -_DISCONNECT_c0


Any help or thoughts on this would be appreciated!

TOPICS
Scripting
465
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

Community Expert , Jun 24, 2015 Jun 24, 2015

Hi subieguy2‌,

SW always follows an underscore or is behind of one?

SW is always in capitals?

This could be a workaround (but it is a little bit like the flying words "a shot from behind through the chest in the eye")

var theTF = app.activeDocument.textFrames;

var TF_len = theTF.length;

var aCon;

for (i = 0; i <TF_len; i++) {

    aCon = theTF.contents;

    if (aCon.match(/_SW|SW_/) != null) {

        aCon = aCon.replace(/_SW|SW_/,"");

        aCon = "SWITCH_" +aCon;

        theTF.contents = aCon;

...
Translate
Adobe
Community Expert ,
Jun 24, 2015 Jun 24, 2015

Hi subieguy2‌,

SW always follows an underscore or is behind of one?

SW is always in capitals?

This could be a workaround (but it is a little bit like the flying words "a shot from behind through the chest in the eye")

var theTF = app.activeDocument.textFrames;

var TF_len = theTF.length;

var aCon;

for (i = 0; i <TF_len; i++) {

    aCon = theTF.contents;

    if (aCon.match(/_SW|SW_/) != null) {

        aCon = aCon.replace(/_SW|SW_/,"");

        aCon = "SWITCH_" +aCon;

        theTF.contents = aCon;

        }

    }

Perhaps someone else knows a better way.

Have fun

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 ,
Jun 24, 2015 Jun 24, 2015
LATEST

That is EXACTLY what I was looking for! Thanks so much!

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