Question
Allow backslash (\) during special characters validation
My requirement is to allow only -,/,\,( and ) and restrict all other special characters. I tried below expression and edit validate rule. Both of them are not allowing backslash (\). Please suggest proper syntex.
Expression:
@String.pxContainsSpecialCharacters(Param.DocNo,"-,/,\\,(,)")=="true"
Edit Validate:
java.util.regex.Pattern pattern=java.util.regex.Pattern.compile("[^A-Za-z &@'()-./0-9!#$%*_={}|:;<>\\~^]");
java.util.regex.Matcher match=pattern.matcher(new String(theValue));
boolean status= match.find();
if(status)
{return false;}
else
{return true;}
Thank you.
Hi Nandhini
Could you check below function for validation of special characters -,/,\,( and )
@(Pega-RulesEngine:String).pxContainsViaRegex(Param.DocNo,"[-/\\\\()]",true)
Hope it helps. Let me know if you observe any issues using above function.