Hello Developer,
I am writing this email regarding an issue with the command ˇ§egrepˇ¨, I wrote the following script and try to get a user to enter their postal code in the correct format, otherwise, it will not pass.
As you can see, the format should be
[[:upper:]][[:digit:]][[:upper:]][[:space:]][[:digit:]][[:upper:]][[:digit:]]
I want to give the user an error if they enter more than one space, but it did not work.
Still exit the while loop even if the user enters more than 1 space
I have tried the following, and it did not work as I expected:
'^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$'
'^[A-Z][0-9][A-Z]\s[0-9][A-Z][0-9]$'
'^[A-Z][0-9][A-Z][[:space:]][0-9][A-Z][0-9]$'
'^[A-Z][0-9][A-Z][[:space:]]{1}[0-9][A-Z][0-9]$'
What would be the correct way to limit users entering 1 space only?
I really appreciate your time to address this issue, hope you have a wonderful day.
Wilson.