首页 > 解决方案 > Illustrator - 仅通过显式名称选择图层

问题描述

此脚本选择包含单词“shadow”的每一层,但它也会选择包含该单词的任何层。

例如,我如何明确地只选择“shadow”和“shadow-7”以便它忽略“shadow-4”、“shadow-5”等?

var aDoc = app.activeDocument;
var pI = aDoc.pageItems;
aDoc.selection = null;
for (i=pI.length-1; i>=0; i--) {
    if (pI[i].name.match(/shadow/i) != null) {
        pI[i].selected = true;
        }
    }

标签: adobe-illustrator

解决方案


您需要将您的正则表达式更改 /shadow/i/^shadow$/i


推荐阅读