Solved

Form data entry Validation for Serial Numbers using Regular Expression

Posted on 2014-03-26
9
577 Views
Last Modified: 2014-06-19
My form was created by a programmer who is no longer available to perform coding edits.  He created a web form that validates Serial Numbers with a regular expression.

Here is the current regular expression:
[gtGT][\s\-]*\d{4}[\s\-]*[\w\W]\d{2}[\s\-]*\d{4,5}[\s\-]*

I need this regular expression to be modified so that additional Serial Numbers will be validated if they start with an I or i or L or l.  That is, uppercase or lowercase I or L.  The validation of S/N's starting with [gtGT] is still required.
0
Comment
Question by:plord1234
  • 3
  • 3
  • 2
9 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 150 total points
ID: 39957244
Do you mean you want to change [gtGT] to [gtGTIiLl],
or do you want to add [IiLl]? in front of the [gtGT]
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 39957388
[a-d] or [abcd] matches any single character from a to d. If you understand that much, then ozo's suggestions should now make some sense if you didn't know it already.

Let us know if you'd like some advice on learning regular expressions, or even just how the given pattern works.
0
 

Author Comment

by:plord1234
ID: 39959526
To pass validation any S/N value entered must start with one of the characters in the following list: (g, t, l, i, G, T, L, I).

The remainder of the conditions in the expression will remain unchanged.

Your advice on learning about regular expressions and how the given pattern works would be most welcome.

Thanks
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 350 total points
ID: 39960131
Then ozo's suggestion to change [gtGT] to [gtGTIiLl] should work for you.

http://www.regular-expressions.info/ is a good site with some tutorials to work through, and has excellent notes on the limitations/capabilities of the regular expression engine used by different tools and languages (click the Applications and Languages link).

There is a Regular Expressions Topic Area here on EE which normally gets a high quality response to your questions within a few hours. There are some good articles there too, including a great one on "look around" which is an important technique to understand once you've already learnt the basic concepts.
0
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

 

Author Comment

by:plord1234
ID: 39960290
Hmm.  I tried  [gtGTIiLl] even before I posted this question.  It did not work.  I think I need to study the whole expression meaning.  I may come back to this, so I will not close the question out just yet.

Thanks Terry.
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 39960294
Feel free to provide some sample data for us to test too.
0
 
LVL 84

Expert Comment

by:ozo
ID: 39960451
When you say it did not work, do you mean there were strings it should have matched which did not match, or that there were strings which should not have matched which did match?
Can you provide examples of such?
Did the original regular expression work correctly in those cases?
0
 

Author Comment

by:plord1234
ID: 39972011
Both answers were accurate.  Terry provided references to more detailed help.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

15 Experts available now in Live!

Get 1:1 Help Now