Solved

Regular Expression for checking valid value from file

Posted on 2007-04-03
4
1,228 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
Comment Utility
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
Comment Utility
egrep -v '^[A-HJ-NPR-Z0-9]{11}[0-9]{6}$' YourDataFile
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

772 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

14 Experts available now in Live!

Get 1:1 Help Now