ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
At work, I run the product scriber. The scriber scribes the product number on the product. A typical product number is
C-1234567-01-A3 (for example)
The C and the hyphens never change. So basically all valid scribes are of the form
C-*some seven numerical digits*-*some two numerical digits*-*some alphanumeric checksum*
I'm not a programmer but I need to ask the programmer to check the scribe's form. I don't want to actually read the scribe and see if it's correct, I just need to verify the syntax, so that we can raise a flag if there's no way it could be correct.
I want to communicate the requirements for a valid scribe syntax with a regex so that later there's no ambiguity about what I asked for. Problem is I don't know how to express it precisely. I originally came up with
C-[0-9]-[0-9]-[A-Z0-9]
This says what the 3 fields can contain, but it doesn't express the fact that the first number must be exactly 7 numeric digits, and the sequence number must be exactly 2, and the checksum must be exactly 2 alphanumeric digits.
How can I communicate these requirements unambiguously in a form that any programmer will understand?
Cool, I created a text file containing a bunch of phony product numbers and one good product number, and now I'm using grep to test my regex. Surprisingly it pulled out a number I intended as a phony. I'm not sure it's a problem though, because checksums might not always contain letters. I'm not sure about that. I guess I need to know more about my checksum.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.