Copy link to clipboard
Copied
so, in a script i need to remove the text from the begining of the paragraph until the first tab (or dot or colon or "something") charater as simple and as fast as posible.
i was hoping for something like
myText=myParagraph.characters.itemByRange(0,"\t");
myText.remove();
Ofcourse i can use grep, but it has it's problems, and i was hoping i don't have to (especialy since the script will have to do this for 400+ times.
Any help?
Vamitul
I don't know if that's the way do go about it but this is what you are looking for.
myParagraph=app.selection[0].paragraphs[0];
myText=myParagraph.characters.itemByRange(0,myParagraph.contents.toString().indexOf("\t"));
myText.remove();
To delete until the tab not including it use myText=myParagraph.characters.itemByRange(0,myParagraph.contents.toString().indexOf("\t")-1);
Trevor
Message was edited by: ~ Trevor ~
Copy link to clipboard
Copied
Vamitul
I don't know if that's the way do go about it but this is what you are looking for.
myParagraph=app.selection[0].paragraphs[0];
myText=myParagraph.characters.itemByRange(0,myParagraph.contents.toString().indexOf("\t"));
myText.remove();
To delete until the tab not including it use myText=myParagraph.characters.itemByRange(0,myParagraph.contents.toString().indexOf("\t")-1);
Trevor
Message was edited by: ~ Trevor ~
Copy link to clipboard
Copied
Thank you.
that's how i did it, but i think it's kind of a very ugly hack.
Also text.contents already returns a string, so no need for .toString();
Copy link to clipboard
Copied
Pleasure
The .toString() is a bit safer.
Try the script with the first line
myParagraph=app.selection[0].paragraphs.everyItem();
It works with the toString and doesn't without.
So it depends on how you define myParagraph
But as you wrote myParagraph and not myParagraphs you probably don't need the toString()
Copy link to clipboard
Copied
.everyItem() returns a array of paragraphs, so ofcourse it doesn't work. Anyway the paragraph part was a simplification. The actual code i needed was:
fNote.characters.itemByRange(0,fNote.contents.indexOf(separator)-1).contents=doc.footnoteOptions.prefix+String(j+1)+doc.footnoteOptions.suffix;
I had to make a script to change/restart the footnote numbering on a "per frame" basis.