Question
international sos
ES
Last activity: 31 Oct 2019 2:51 EDT
UTF characters problem over a validation rule
Hi guys!
I'm having a little bit problem. I'm making a Validation Rule to test an email address (because the PEGA validation only see if you've an "@", so it's not a valid one) using the "ñ" character (an special character from Spain. UTF-8) over the regular expresion. Nothings matter and the email is not validate it.
Ok... so I decided to replace all the "ñ" characters over the string (theValue) and then validate it without these characters... again, nothing matters.
Could you help me to improve something to do this? I'm over Pega 8.2.1 Cloud and i suppose that my cloud machine don't have the UTF8 encoding....
A testing email address (property value - text):
jaimeñ[email protected]
The java code:
if (theValue== null || theValue.trim().equals("")) return false;
String mail = theValue.toString();
if (mail.indexOf("ñ") >0 ) { //"escaping" "ñ" character...
mail = mail.replace("ñ", "n");
}
//first pattern. Working fine over other plattform, don't at PEGA
//"^([a-z0-9ñ])+([a-z0-9._ñ-])*(@){1}([a-z0-9ñ]){1}(([a-z0-9_ñ-])((\\.){1}([a-z0-9_ñ-]))*)+((\\.){1}([a-z]){2,4})+$";
//second pattern
String regex = "^(?!\\.)(([^\\r\\\\]|\\\\[\\r\\\\])*|([-a-z0-9!#$%&'*+/=?^_`\\{|\\}~]|(?<!\\.)\\.)*)(?<!\\.)@[a-z0-9][\\w\\.-]*[a-z0-9]\\.[a-z][a-z\\.]*[a-z]$";
if (mail.matches(regex) ){
return true;
}else{
return false;
}
Thanks in advance!
***Edited by Moderator: Lochan to update platform capability tags***