Skip to main content
karth80472045
Inspiring
June 11, 2017
Question

identify group name

  • June 11, 2017
  • 2 replies
  • 479 views

hello everyone ,

i have a doubt it is possible to identify group name for this type

how to identify this group names in if condition

please help me .

with regards,

karthi

This topic has been closed for replies.

2 replies

karth80472045
Inspiring
June 11, 2017

thank you so much sir !!! it is working.

pixxxelschubser
Community Expert
Community Expert
June 11, 2017

If I understand you right you can try

var groupAname = "M34:D18:";

var groupBname = "B57:D40:";

var wrongCname = "b57;D40:";

check(groupAname);

check(groupBname);

check(wrongCname);

function check (nme) {

    var reg = /^([A-Z]\d{2}:){2}/;

    if( reg.test( nme ) == false) { 

        alert ("no match: "+ nme); return; } 

    else { alert ("match found: "+nme) }

    }

or

var groupAname = "M34:D18:";

var groupBname = "B57:D40:";

var wrongCname = "b57;D40:";

var reg = /^([A-Z]\d{2}:){2}/;

if( reg.test( groupAname ) == true) {

    alert("match "+groupAname + " = true");

    }

    else {

        alert("match "+groupAname + " = false");

        }

if( reg.test( groupBname ) == true) {

    alert("match "+groupBname + " = true");

    }

    else {

        alert("match "+groupBname + " = false");

        }

if( reg.test( wrongCname ) == true) {

    alert("match "+wrongCname + " = true");

    }

    else {

        alert("match "+wrongCname + " = false");

        }

If so

Have fun

karth80472045
Inspiring
June 11, 2017

hello sir,

Thanks for the reply , i have many group Items

i am looping groupItems

like this

var sourceDoc=app.activeDocument;

var reg = /^([A-Z]\d{2}:){2}/; 

for(var j=0;j<sourceDoc.groupItems.length;j++)

{

    if(sourceDoc.groupItems.name== reg)

how can i match group name in if condition

pixxxelschubser
Community Expert
Community Expert
June 11, 2017

Hi Yogesh,

does this helps you on your way?

var sourceDoc=app.activeDocument;

var grp = sourceDoc.groupItems;

var reg = /^([A-Z]\d{2}:){2}$/;

for ( var j=0; j<grp.length; j++ ) {

    if( check(grp.name) ) {

        alert(grp.name + " found");

        }

    }

function check (nme) {

    if( reg.test( nme ) == false) {

        return false; }

    return true;

}

Have fun