🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #8333

Re: how do i write a text search-replace routine?

#8333
From: Peter_Kahrel
Date: Wed, 18 Oct 2006 12:17
21 lines
1622 bytes
You can't search capital letters in Indesign, but that's easily overcome by using a regular expression. Make sure you have a text frame or an insertionpoint selected, then use the script below. A thread is called a Story in Indesign; parentStory of an insertionpoint or frame gives you the story as an object. Apply the regex to its contents. You process the resulting array (here, 'caps') using Indesign's search/replace.

As to finding out about the object model using the ESTK, see <http://www.oreilly.com/catalog/scriptingindesign/>

Hope this helps.

Peter



thread = app.selection[0].parentStory; 
caps = thread.contents.match( /[A-Z]{2,}/g ); 
if( caps != null ) 
   { 
   app.findpreferences = app.changePreferences = null; 
   // change following line to any other capitalization if necessary 
   app.changePreferences.capitalization = Capitalization.smallCaps; 
   for( i = 0; i < caps.length; i++ ) 
      thread.search( caps[i], false, true, 
         caps[i].toLowerCase() ); 
   }
Technical Details
Message-ID: <3bc20122.0@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossing
References: <3bc20122.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,c66069b42277bf0e
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Peter_Kahrel@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: how do i write a text search-replace routine?
Message-ID: <3bc20122.0@webcrossing.la2eafNXanI>
Date: Wed, 18 Oct 2006 05:17:06 -0700
References: <3bc20122.-1@webcrossing.la2eafNXanI>
Lines: 29
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossing