Solved

Form data entry Validation for Serial Numbers using Regular Expression

Posted on 2014-03-26
9
587 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
[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
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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
 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime is disastrous for companies and can lead to major hits on a brand, reputation, an…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

730 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