Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Perform grep search

$
0
0

Hi folks,

 

I was wondering whether it was possible to find and replace using grep. I have the find and replace thing sorted, but I need it to be flexible enough to select any number and alter the value by a set amount. I have done this in InDesign but have become stuck with Illustrator.

 

I have tried to use an adapted version of the search script from this thread: (CarlosCanto)

 

var multiplier = parseFloat(2.5);

 

var search_string = /[-]*[0-9][0-9,.]*\\b/gi;

var replace_string = search_string * multiplier;

 

var text_frames = active_doc.textFrames;

 

if (text_frames.length > 0) {

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

        var this_text_frame = text_frames[i];

        var new_string = this_text_frame.contents.replace(search_string, replace_string);

 

        if (new_string != this_text_frame.contents) {

            this_text_frame.contents = new_string;

        }

    }

}

 

This simply returns 'undefined'

 

Do I need to invoke a grep function to parse the pattern through?

 

Any help would be wonderful.

 

Thanks


Viewing all articles
Browse latest Browse all 12845


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>