| | |
Input Validation
![]() |
•
•
Join Date: Oct 2008
Posts: 23
Reputation:
Solved Threads: 0
Hi,
I need to validate user input to ensure it is alphabet characters only. I know there must be a simple solution but evertything I have tried has either partially failed or totally failed.
At the moment, I have this:
and it works but allows at least spaces (possibly other unwanted characters, too) and I can't use that. I know very little of grep so if some kind person will point out where I'm going wrong, I'll be most grateful.
Thanks.
I need to validate user input to ensure it is alphabet characters only. I know there must be a simple solution but evertything I have tried has either partially failed or totally failed.
At the moment, I have this:
until [ $(echo "$myVar" | grep -v '[^a-zA-Z]') ]
do
read -p "Enter some text" myVar
doneand it works but allows at least spaces (possibly other unwanted characters, too) and I can't use that. I know very little of grep so if some kind person will point out where I'm going wrong, I'll be most grateful.
Thanks.
Last edited by Roybut; Aug 8th, 2009 at 12:03 pm.
try
bash Syntax (Toggle Plain Text)
until [ $(echo "$myVar" | grep -e '^[a-zA-Z]*$') ] do read - p "Enter some text" myVar done
•
•
Join Date: Oct 2008
Posts: 23
Reputation:
Solved Threads: 0
•
•
•
•
try
bash Syntax (Toggle Plain Text)
until [ $(echo "$myVar" | grep -e '^[a-zA-Z]*$') ] do read - p "Enter some text" myVar done
Perfect. Thank you. I searched Google for an age but couldn't find this.
![]() |
Similar Threads
- Input Validation With scanf (C)
- input validation (C)
- change the color for DBGrid row; Input Validation code help!! (Visual Basic 4 / 5 / 6)
- C++ array input validation help. (C++)
- Input Validation (VB.NET)
Other Threads in the *nix Software Forum
- Previous Thread: Latest Kernel
- Next Thread: Need suggestions for sql software
| Thread Tools | Search this Thread |





