The UNIX and Linux Forums  

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


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regular Expressions ramky79 UNIX for Advanced & Expert Users 3 05-21-2008 02:13 PM
Help with regular expressions arushunter Shell Programming and Scripting 13 12-23-2006 08:31 PM
regular expressions jack1981 Shell Programming and Scripting 4 07-12-2006 12:10 PM
regular expressions in c++ szzz High Level Programming 2 10-06-2003 07:33 AM
Regular Expressions AresMedia Shell Programming and Scripting 1 08-22-2002 12:55 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2007
Registered User
 

Join Date: Jul 2006
Posts: 145
regular expressions

Hi Gurus,

I need help with regular expressions. I want to create a regular expression which will take only alpha-numeric characters for 7 characters long and will throw out an error if longer than that.

i tried various combinations but couldn't get it, please help me how to get it guys.

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-05-2007
zazzybob's Avatar
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
  #3 (permalink)  
Old 03-05-2007
Registered User
 

Join Date: Jul 2006
Posts: 145
thanks for ur reply, it worked..
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
regex, regular expressions

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0