Scripting question: Regex expression in glide filters

Nitesh Balusu
Giga Guru

This script doesn't seem to be working, any thoughts on this please? Is this the way we use a Regex expression in glide filters? Also, my expression is ATF followed by a 5 digit number, I hope the expression is correct?

 

var re= new RegExp('ATF[0-9]{5}');
var a= new GlideRecord('sys_user_group');
a.addQuery('name','STARTSWITH',re);
a.query();
if(a.next())
{
gs.print("found");
}

else
gs.print("not found);
1 ACCEPTED SOLUTION

Nitesh Balusu
Giga Guru

Got it myself:

GlideFilter and Regular Expression Match

This is a great blog.

 

var filter= 'nameMATCH_RGXATF[0-9]{5}.*';  //name starts with ATF followed by 5 digit number

var a= new GlideRecord('sys_user_group');
a.query();

while(a.next())
{
if (GlideFilter.checkRecord(a, filter)) 
gs.print(a.name);

}

View solution in original post

1 REPLY 1

Nitesh Balusu
Giga Guru

Got it myself:

GlideFilter and Regular Expression Match

This is a great blog.

 

var filter= 'nameMATCH_RGXATF[0-9]{5}.*';  //name starts with ATF followed by 5 digit number

var a= new GlideRecord('sys_user_group');
a.query();

while(a.next())
{
if (GlideFilter.checkRecord(a, filter)) 
gs.print(a.name);

}