Solved

Form data entry Validation for Serial Numbers using Regular Expression

Posted on 2014-03-26
9
594 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

729 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