I have the following expression,
var exp = new RegExp('^[a-zA-Z0-9]' + getMinMax() + '$');
My getMinMax() function returns the value dynamically ex {2,5} , etc!
But it returns an exception, it says that syntax error in regular expression. How can i correct it?
function getMinMax() {
var minLength = Rule.MinimumLength,maxLength = Rule.MaximumLengh;
var limitExpression = (minLength != 'undefined' && minLength != null ) ? minLength.toString() : '';
limitExpression = (maxLength != 'undefined' && maxLength != null ) ? (limitExpression != '' && limitExpression != null) ? ('{' + limitExpression + ',' + maxLength.toString() + '}') : ('{' + maxLength.toString() + '}') : '';
return limitExpression;
}
getMinMax()returns the string"{2,5}"?getMinMax(). I guarantee you it is something other than{x, y}.