Thank you for your tip and I apply your script to my own's
In my case, It is the same finding words at the end of each column that does not end with a space, forced line break, or a hyphen) as finding the regular expression [a-z] at the end of each column .
I change my thought to fine the [a-z] at the end of each column and underline those.
So I setup the belows script. But it doesn't works.
I am the beginner of the scirpt. Please help me.
//DESCRIPTION: Begone, Ugly End Of Line Underlining!
// (c) Jongware 16-Dec-2009
var blankStyle = app.activeDocument.characterStyles.item(“Underline”);
try { blankStyle.index; } catch(_)
{
blankStyle = undefined;
}
if (blankStyle == undefined)
{
blankStyle = app.activeDocument.characterStyles.add();
blankStyle.name = “Underline”;
blankStyle.underline = true;
}
var myDocument=app.documents.item(0);
var findWhat=”[a-z]”;
app.findGrepPreferences=NothingEnum.nothing;
app.changeGrepPreferences=NothingEnum.nothing;
app.findGrepPreferences.findWhat=findWhat;
var myFoundItems=myDocument.findGrep();
for (a=0; a<app.selection[0].lines.length; a++)
{
if (app.selection[0].lines[a].characters.item(-1).contents == myFoundItems)
app.selection[0].lines[a].characters.item(-1).appliedCharacterStyle = blankStyle;
}