InDesign:Javascript grep段落中的最后一个匹配项

时间:2017-06-20 16:11:59

标签: javascript grep adobe-indesign

我在这里有InDesign中的文字:

Hello (World),
this (nonsense) text
nobody (needs, right?).

使用我的jsx脚本,我想选择括号为(needs, right?)的最后一个匹配项。 但是这个结果用常规和斜体格式化(needs是斜体,其余的是常规的)。但我只想改变常规风格。

我脚本中的部分如下所示:

function myFindGrep(myObject, mySearchString, mySearchStyle, myStyleGroup, myStyle){
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat = mySearchString;
    app.findGrepPreferences.fontStyle = mySearchStyle;
    app.changeGrepPreferences.appliedCharacterStyle = myDocument.characterStyleGroups.item(myStyleGroup).characterStyles.item(myStyle);
    var myFoundItems = myObject.changeGrep();
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences = NothingEnum.nothing;
}

myFindGrep(selText.paragraphs.item(x), "\(.+?\)", "Regular", "Meist genutzte", "Zitat Regular");

当我应用它时,它会改变我的洞选择,除了斜体文本......

有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:0)

我不得不修改我的功能,做第二次grep:

var t = new Transmission();

t.Content.From.Email = "from@thisperson.com";
t.Content.TemplateId = "my-template-email";

new Recipient
{
    Address = new Address { Email = recipient }
}
.Apply(t.Recipients.Add);


new Attachment
{
    Data = //CSVDATA,
    Name = "Table.csv",
    Type = "text/csv"
}.Apply(t.Content.Attachments.Add);


var client = new SparkPost.Client(Util.GetPassword("sparkpostapikey"));
client.Transmissions.Send(t).Wait();