Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-08-2004, 10:47 AM   #1
John Sloan
LQ Newbie
Registered: Sep 2004
Location: Los Angeles
Posts: 1

Rep: Reputation: 0
Regular expression question -

I need a regular expression to validate Social Security numbers.

The match number will be 9 digits (no spaces or dashes) and can not begin with three zero's (000) and also cannot begin with a nine (9).


002334444 Pass
888223333 Pass

000112222 Fail
911223333 Fail

Last edited by John Sloan; 09-08-2004 at 10:50 AM.
Old 09-08-2004, 12:33 PM   #2
Senior Member
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 52
grep -w '.\{9\}'

will kick out the ones that are 9 characters long

egrep -w '(9|000).*'

will kick out the failed ones
from the 9 or 000 at the start

grep '-'

will kick out -'s

grep '.[[:space:]].'

will kick out ones with spaces

Last edited by foo_bar_foo; 09-08-2004 at 12:37 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expression question gauge73 Linux - General 5 10-28-2005 11:33 AM
Regular expression question gauge73 Linux - General 2 10-28-2005 09:32 AM
regular expression question zero79 Linux - Software 1 07-11-2005 07:03 PM
Regular expression question. groentebroer Programming 2 11-29-2004 09:15 PM
regular expression question Gantrep Linux - Software 2 04-20-2003 04:24 PM

All times are GMT -5. The time now is 07:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration