"/" and "\" are just two of the many special chars used in regular expressions. The forward slash is used to start and stop the pattern when creating an implicit RegExp like /lit+.*specular./
That same expression could be created explicitly like this new RegExp(lit+.*specular.). Notice the forward slashes are not used in the last example.
The back slash is used to either give a char a special meaning or take away the special meaning of some chars.
/d/ means match a single 'd' char. /\d/ means match a single digit char( 0-9 )
/./ means match any single char. /\./ means match a single dot char.
Select by part of name
Select by part of name
Hmm interesting... thanks !
So I've been scriptig quite a lot and I hit another issue. Not sure why its happening. I got it to work with fixed variables but when I want to reference one it changes belnding mode of everything rather than layer I want...
So this one works
Code: Select allvar doc = app.activeDocument;
layerHolder=[]
Sets =doc.layerSets
function editLayer(docSets) {
for (var i=0; i<docSets.length; i++) {
editLayer(docSets.layerSets);
for(var a=0; a < docSets.artLayers.length; a++) {
var layer=docSets.artLayers[a];
var layerName = docSets.artLayers[a].name;
if (layerName.match(/.*ABC_123*./)) {
layerHolder.push(docSets.artLayers[a])
}
}
}
for( var a = 0;a<layerHolder.length;a++){
layerHolder[a].blendMode = BlendMode.NORMAL;
}
layerHolder=[]
}
editLayer(Sets)
But if I write it this way :
Code: Select allvar doc = app.activeDocument;
layerHolder=[]
Sets =doc.layerSets
function editLayer(docSets,tag) {
for (var i=0; i<docSets.length; i++) {
editLayer(docSets.layerSets);
for(var a=0; a < docSets.artLayers.length; a++) {
var layer=docSets.artLayers[a];
var layerName = docSets.artLayers[a].name;
if (layerName.match(tag)) {
layerHolder.push(docSets.artLayers[a])
}
}
}
for( var a = 0;a<layerHolder.length;a++){
layerHolder[a].blendMode = BlendMode.NORMAL;
}
layerHolder=[]
}
editLayer(Sets,/.*ABC_123*./)
It changes blending mode of everything...
What am I doing wrong here?
Thanks, bye.
So I've been scriptig quite a lot and I hit another issue. Not sure why its happening. I got it to work with fixed variables but when I want to reference one it changes belnding mode of everything rather than layer I want...
So this one works
Code: Select allvar doc = app.activeDocument;
layerHolder=[]
Sets =doc.layerSets
function editLayer(docSets) {
for (var i=0; i<docSets.length; i++) {
editLayer(docSets.layerSets);
for(var a=0; a < docSets.artLayers.length; a++) {
var layer=docSets.artLayers[a];
var layerName = docSets.artLayers[a].name;
if (layerName.match(/.*ABC_123*./)) {
layerHolder.push(docSets.artLayers[a])
}
}
}
for( var a = 0;a<layerHolder.length;a++){
layerHolder[a].blendMode = BlendMode.NORMAL;
}
layerHolder=[]
}
editLayer(Sets)
But if I write it this way :
Code: Select allvar doc = app.activeDocument;
layerHolder=[]
Sets =doc.layerSets
function editLayer(docSets,tag) {
for (var i=0; i<docSets.length; i++) {
editLayer(docSets.layerSets);
for(var a=0; a < docSets.artLayers.length; a++) {
var layer=docSets.artLayers[a];
var layerName = docSets.artLayers[a].name;
if (layerName.match(tag)) {
layerHolder.push(docSets.artLayers[a])
}
}
}
for( var a = 0;a<layerHolder.length;a++){
layerHolder[a].blendMode = BlendMode.NORMAL;
}
layerHolder=[]
}
editLayer(Sets,/.*ABC_123*./)
It changes blending mode of everything...
What am I doing wrong here?
Thanks, bye.
Select by part of name
I am not sure that either examples are good ways to write a recursive function. But the problem with the second example is you are not passing the tag argument in the recursive call
editLayer(docSets.layerSets);
should be
editLayer(docSets.layerSets,tag);
editLayer(docSets.layerSets);
should be
editLayer(docSets.layerSets,tag);