Use of backslash with REGEX in JS Window or Conditional Actions in "Advanced action" .
I have a issue with backslash \ character in REGEX verification test() !
in JS Window or Conditional Actions in "Advanced action" ( IF Then "Execute Javascript " Else )
When I use \d , \w or \. in REGEX with the Execute Javascript, it doesn't work, always FALSE value even if it's correct p.e. : CONSA123
First example:
var BC_ID_Smart= window.cpAPIInterface.getVariableValue('v_BC_ID_Smart') ;
var re = /^(CONSA|CONSU|ASTRO|SPONS|COMET|COSMO|ATLAS)\d{3}$/g ;
if (re.test(BC_ID_Smart)) {
window.cpAPIInterface.setVariableValue('v_correct_ID_Smart',1);
} else {
window.cpAPIInterface.setVariableValue('v_correct_ID_Smart',0);
}
solution in this case: I replaced \d with its equivalent expression [0-9] and it works perfectly !
var re = /^(CONSA|CONSU|ASTRO|SPONS|COMET|COSMO|ATLAS)[0-9]{3}$/g ;
But with this another example:
To do email validation, I need to use \. to specifically use a dot (or more) in email.
Also, I replaced \w by its equivalent [a-zA-Z0-9_]
But there is a problem, Captivate sees only "."(the dot and not backslash) witch means "any character" in REGEX!.
I can conclude that Captivate skip or doesn't like the use of \ (backslash):
var BC_email= window.cpAPIInterface.getVariableValue('v_BC_email') ;
var re = /^([a-zA-Z0-9_+-]+(\.[a-zA-Z0-9_+-]+)*)@([a-zA-Z0-9]+(-*[a-zA-Z0-9])+\.)+([a-zA-Z]{2,})$/g ;
if (re.test(BC_email)) {
window.cpAPIInterface.setVariableValue('v_Etat_email',1);
} else {
window.cpAPIInterface.setVariableValue('v_Etat_email',0);
}
My REGEX email validation, then, doesn't work correctly in Captivate9
because of the use of \.
and there is no equivalent to bypass the issue like the first example....
Does anyone can help ?
How to Ask Adobe programmers to fix that BUG ?
