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
Solved

Form data entry Validation for Serial Numbers using Regular Expression

Posted on 2014-03-26
9
585 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
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
repair install of Windows 10 stuck on Looking for Updates 5 38
VB.NET 2008 Winforms Signing 13 30
Un-Indent Setting Notepad++ 3 18
BATCH to EXE Converter 2 32
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 …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

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