Solved

regular expression

Posted on 2009-04-05
4
279 Views
Last Modified: 2012-05-06
Hello

I need to search for P123/ABC using a regular expression?

Thanks for your help
0
Comment
Question by:Skycapt
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:cubeeq
ID: 24073588
Could you be more specific? You can find this exact expression when you just call it: P123/ABC.
0
 
LVL 1

Author Comment

by:Skycapt
ID: 24075433
Oh sorry,

I have a list of products P123 to P500 in number order but 5 or 6 of them have the extended code P123/ABC the numbers and letters may vary so you may get P234/DEF they also may change from day to day so I cant just isolate individual codes.

Hope that helps
0
 
LVL 3

Accepted Solution

by:
cubeeq earned 250 total points
ID: 24075699
ok, the most general variant is "P[0-9][0-9][0-9](/[A-Z][A-Z][A-Z])?" - it also matches P000/AAA, you can narrow it to "P[1-5][0-9][0-9](/[A-Z][A-Z][A-Z])?" and so on. if you want the most specific thing, i will post something more complex.
0
 
LVL 1

Author Closing Comment

by:Skycapt
ID: 31566842
Hi, thanks for your help, here's my final code

'^[P][0-9]{3}(/[A-Z]{3})?$'
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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

910 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

25 Experts available now in Live!

Get 1:1 Help Now