Solved

Regular Expression for checking valid value from file

Posted on 2007-04-03
4
1,229 Views
Last Modified: 2013-12-26
This is kind of urgent. I was wondering if someone can help me with a regular expression that checks for:

VIN should have only A-Z, 0-9 characters, but not I, O, or Q
Last 6 characters of VIN should be a number
VIN should be 17 characters long.

I have a text file which contains all the VINs one after the other. So I need to read each VIN from the file
and find out the ones which are not valid.

An actual example is helpful. The script is written in korn shell.

Thanks
0
Comment
Question by:hcdev
4 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 250 total points
ID: 18847468
cat YourDataFile  | egrep -e '^[A-HJ-NPR-Z0-9]{17}$' | egrep -e '[0-9]{6}$'
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 250 total points
ID: 18847545
egrep -v '^[A-HJ-NPR-Z0-9]{11}[0-9]{6}$' YourDataFile
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Utilizing an array to gracefully append to a list of EmailAddresses
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now