I have a requirement where I need to match string which satisfies all of the below requirements -
- String must be of length 12
- String can have only following characters - Alphabets, Digits and Spaces
- Spaces if any must be at the end of the string. Spaces in between are not allowed.
I have tried with below regex -
"^[0-9a-zA-Z\s]{12}$"
Above regex is satisfying requirement #1 and #2 but not able to satisfy #3. Please help me to achieve the requirements. Thanks in advance !!