Solved

Regular Expression for checking valid value from file

Posted on 2007-04-03
4
1,233 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux  Script File Attributes 5 75
Capture logon name 13 100
REReplaceNoCase help 1 48
Powershell Timeout - Exchange 3 91
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…

713 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