See, in my Ruby on Rails application, Regex expression is being used for Validation done using jQuery Validation Engine. So, I need a regex for a custom requirement,
My requirement:
It should contain only alphabets, numbers, special characters
#, _, -, (, ), ., *and whitespace.It should start with an alphabet or number, or special characters
#OR*It should end with an alphabet or number, or special characters
.OR)It should not allow consecutive special characters
It should check that for any starting parentheses '(', there is a closing parentheses ')'
It should limit the whole character length to 25
I have tried the below expression in rubular.com:
/^([a-zA-Z]|\d|\#|\*)(([a-zA-Z]*\d*\(?\)?\-?\.?)*)([a-zA-Z]|\d|\)|\.)$/
But, for the above expression,
It will allow combinations like '*)', '()','*.' etc. It should have at least a character or number between the special characters. Also, now it will not check for starting parentheses '(' even though we enter ')'. So, these are the issues.
Can anyone just help me out.