Copy link to clipboard
Copied
I would like to create a script that will simply adds tabs after the (number and the period). I was trying the ChainGrep, but cant find a way to execute it. I tried using find and replace as one of the ChainGrep:
FIND: \d. REPLACE: \d.\t but it simply replace the number as "\d.\t" converted to chracters. Is there any way to execute this? Thanks in advance.
Did you try:
FIND: (\d+\.)\s
CHANGE: $0\t
Better yet, why not strip the manual numbering out in favor of a numbered Paragraph Style?
Copy link to clipboard
Copied
When you execute your changes, change a paragraph style to the one with proper tab alignment set. Then in your changeGrep properties:
{changeTo: "$0\\t~i", appliedParagraphStyle: "aCleanStyle"}
Copy link to clipboard
Copied
Hi @brianp311
For reasons I don't understand, the OP definitely doesn't want to use paragraph formats at all.
Copy link to clipboard
Copied
Well, they are going to be in for a sad surpise when they realize they can't change tab stops in changeGrepPreferences.
Copy link to clipboard
Copied
yes it is, but i have set some paragraph style to execute those functions, however Im still looking for a possible way to put the tabstop function on my script
Copy link to clipboard
Copied
The javascript you are showing is a different animal to the chain of GREP searches. You cannot mix the two.
Copy link to clipboard
Copied
Thanks mike, I think I'll stick to the first process you've mention.
Copy link to clipboard
Copied
// by FRIdNGE, Michel Allio [29/04/2021]
var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "(?s)^\\d+\\.\\K\\h+";
app.changeGrepPreferences.changeTo = "\\t";
myFound = myDoc.findGrep();
var F = myFound.length, f ;
for ( f = 0; f < F ; f++ ) {
if ( !myFound[f].tabStops[0].isValid ) myFound[f].tabStops.add({position: "0.125 in"});
else myFound[f].tabStops[0].position = "0.125 in";
myFound[f].tabStops[0].alignment = TabStopAlignment.LEFT_ALIGN;
}
myDoc.changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
(^/)
Copy link to clipboard
Copied
Hi @Mike Witherell I just want to ask, is there a way that I can eliminate single spaces between texts? I have a file that contains "mL/ml" values and I want to remove the spaces between them.
eg: 3 mL to 3mL
I want to include this on the script I am building. Thank you in advance