Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Regular Expression for checking valid value from file

Posted on 2007-04-03
4
Medium Priority
?
1,236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 1000 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 1000 total points
ID: 18847545
egrep -v '^[A-HJ-NPR-Z0-9]{11}[0-9]{6}$' YourDataFile
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

715 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