The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-05-2007
zazzybob's Avatar
zazzybob zazzybob is offline
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Code:
$ echo "123abc7" | grep '^[A-Za-z0-9]\{0,7\}$' || echo ERROR
123abc7
$ echo "123abc78" | grep '^[A-Za-z0-9]\{0,7\}$' || echo ERROR
ERROR
If you want exactly 7 characters, just change the regex to
Code:
'^[A-Za-z0-9]\{7\}$'
Cheers
ZB
Reply With Quote