How to validate regex expression in business rule

MMKK
Tera Expert

Hi All,

I have a requirement to validate regex expression for below entries:

 

AAA00-00-000

1234567890

Please help. 

4 REPLIES 4

rahulpandey
Kilo Sage

Hi,

You can run javascript in business rule like below

var str = "this is test";
var patt = new RegExp("test");
var res = patt.test(str);
gs.print(res);

 

Deepak Ingale1
Mega Sage
var exp = /(AAA00-00-000)/gm
var myString = "AAA00-00-000"
gs.log(exp.test());

 

You can run above code in background scripts . Same can be written in BR then !!!

 

 

MMKK
Tera Expert

BOth didnt work for me in BR:

 

var isValid = false;
var project_code = current.variables.project_code;
if(current.variables.member_firm =='Australia')
{
var regexObj = new Regex("/^\(?([A-Z]{4}\d{3}-\d{2}-\d{2}-\d{2}-\d{4})$/");
if (regexObj.test(project_code))
isValid = true;

 

Always my result was false

you able to came up with the solution , I am facing the same issue