Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Re-Numbering numbers

$
0
0

You need to look for numbers, not digits, so use Grep to find all numbers: \d+

Find all numbers and replace their contents with the value of the for-loop counter. No need to bother with what the contents really are.

Then you must work from the end of the found numbers to the beginning because the length of the numbers wioll change, e.g. 10 (two digits) may change to 9 (one digit). Like this

 

app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '\\d+';
app.findGrepPreferences.position = Position.SUPERSCRIPT;
numbers = myDoc.findGrep();for (i = numbers.length-1; i > -1; i--){    numbers[i].contents = String(i+1);    numbers[i].appliedCharacterStyle = myDoc.characterStyles.item("Sup");}

 

Peter


Viewing all articles
Browse latest Browse all 37788

Trending Articles



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