We help IT Professionals succeed at work.

Regex Needed

Last Modified: 2012-06-27
Dear Experts,

I need to extract a substr that is 17 caracter long and contain no I ,O or Q.
The main string (let s call it $content) has a variable length (if that matters) and the substring can be anywhere within it.

URGENT ! Please Help!

Watch Question


I forgot the substring obtain has no space within it.
And for more information I am looking to extract a VIN number from vehicle history from a database.
This one is on us!
(Get your first solution completely free - no credit card required)



If I did not show the content , it is because of its length. But the "I'm a long sentences with some stuff in it, does it make sense? Who knows" wold work all the same :)
I actually found (dogpiled) in a group something that would do just as well for a VIN number :
if (preg_match('/([A-Z]{3}|\\d{3})[A-Z]{2}\\d{2}([A-Z]{1}|\\d{1})([\\d{1}|X{1})([A-Z]+\\d+|\\d+[A-Z]+)\\d{5}/', $subject)) {
} else {
It does not take the IOQ factor in consideration, however it follows the pattern of the VIN numbers.
Thanks for your help.
Case closed.

That's what I meant with showing us the content. The regular expression for this VIN number looks fine for me (if you happen to know how VIN numbers are build) The good thing about this things is mostly that they are quite regular and do some extend rigid. So if you are looking for such stuff we all are better of if you provide as details information as fits, stripping down your problem to the smallest extend (no-one likes to wade through lines of lines of code just to figure out what may be wrong....


Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.