I've been working on a regex problem for angularJs ng-pattern which needs:
- Cannot be blanks
- A minimum of 1 character and a maximum of 32 characters
- Spaces ONLY are not allowed
- Acceptable special characters(!@#$%&*-+=[]:;',.? )
- The answer is not case sensitive
- Combination of &# is not allowed
- Spaces at the beginning and the end of the answer should be trimmed.
This is my solution which covers all requirement but 6th:
([^a-zA-Z0-9!@#$%& *+=[\]:;',.?-])|(^\s*$)
Do you guys have any ideas?
/^(?!\s*$)(?:(?!&#)[a-zA-Z0-9!@#$%&*+=[\]:;',.?\s-]){1,32}$/. However, I have no idea what your Req. 7 means.ng-patterndoes not trim input text.^(?!\s*$)(?!.*&#)[a-zA-Z0-9!@#$%&*+=[\]:;',.?\s-]{1,32}$