Solved

Form data entry Validation for Serial Numbers using Regular Expression

Posted on 2014-03-26
9
581 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Form Calculate Total Price 10 42
SQL Insert parts by customer 12 34
Help Required 3 97
Server 2012 Hypervisor 2 10
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 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