Skip to main content
Known Participant
October 17, 2015
Answered

Extract text from area text

  • October 17, 2015
  • 1 reply
  • 1080 views

Hi there_

I have an area text and would like to extract red numbers only

and copy to clipboard or to a new point type text.

How can I do this?

See image below!

Many thanks guys

This topic has been closed for replies.
Correct answer pixxxelschubser

Here is the link - 1.6MB Ai file

+ http://rghost.net/7JtbDCvVq


Puthoskey,

try this:

// find_8-digit-number.jsx

// https://forums.adobe.com/thread/1981373

// Extract text from area text

// regards pixxxel schubser

var txtString = app.activeDocument.textFrames[0].contents;

var searchString = /\bart[\s#:\t]+\d{8}/i;

var searchString2 = /\d{8}/g;

var found = txtString.match (searchString);

var showFound = found[0].replace(/\t/," ").replace(/\s+/," ");   // this is only a cleaning for the prompt

var _8digitNumber = found[0].match (searchString2);  // you can use this variable now for saving

prompt ("found this line:\n" + showFound + "\n\nHere is your 8-digit-Number", _8digitNumber);

Furthermore you will need a function to save your file in the format of your choice.

Have fun

1 reply

pixxxelschubser
Community Expert
Community Expert
October 17, 2015

Puthoskey‌,

please give us an example file.

It should be possible, but there are to much questions like:

- what do you want to do with the original texts?

- are there more than one "eight-character-digits" in one text area?

- are there only text areas (or point texts too?)

- are the digits always red?

- how many texts in your document exists? (the more - the longer - the instable)

- …

A good example file will be a file with the status before and after "extract" the "eight-character-digits".

For the ai-file you can use a hoster of your choice e.g. like dropbox or xup.in

PuthoskeyAuthor
Known Participant
October 17, 2015

Hi pixxxel!

+ After extracting the 8 digits, I have to save the .EPS file with that same name.

- Ex: 00259965.eps (I got the code to save the file)

+ There are only text areas (it would be good extract them with point text too.)

+ The digits are always black, you can see the image below.

+ There are many others texts objects.

Many thanks for your help.

pixxxelschubser
Community Expert
Community Expert
October 17, 2015

Please give an example AI-file for testing.