Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:07:47+00:00 2026-06-04T07:07:47+00:00

I have a web application, written in PHP that incorporates Javascript and JQuery, that

  • 0

I have a web application, written in PHP that incorporates Javascript and JQuery, that will be used as my company’s Inventory Management System (IMS). What I would like to be able to create is a Regex expression based upon user input of a value.

The idea behind this is that most manufacturers’ serial numbers schema, length of characters and mixture of alpha to numeric values, is unique to a certain part. So when a part is added to the IMS and the first serial number is scanned into the system I would like a Regex statement to be built and saved to a database table corresponding to that part type. Any future times that a serial number is scanned the part should be auto-selected as the part type as it matches the serial number schema for that manufacturer. I understand this methodology may not always hold true to a single part so I could even return a list of parts that match the schema instead of the user needing to look it up in the catalog.

The basis of my question is what is the best starting point to look at having a function in code be able to decipher a value given by a user to create a Regex expression? I’m not requesting a full function but a starting point of how to look at my situation and goal so I can understand where to begin. I’ve scratched my head long enough and starting writing functions numerous times just to delete the entire block knowing I was headed for disaster.

Anything in code is possible – is this feasible?


EDIT – ADDED SAMPLE VALUES

DVD-RW (Optical Drives)

  • 1613518L121
  • 1613509L121
  • 1613519L121

VGA Output Cards

  • 0324311071068
  • 0324311071134

COM Expansion Cards

  • 608131234
  • 608131237

Hard Drives

  • WMAYUJ753738
  • WMAYUJ072099
  • WMAYUJ683739
  • WMAYUJ844900

As you can see some values are going to be numeric only of a certain length of characters. Others will have alpha characters at the beginning followed by a series of numbers. Others may have alpha/numeric characters interspersed with each other. In most every single case a simple length of alpha/numeric rule is going to fit for identifying a singular part type in our list of goods. However, in those cases that more than one expression matches a value, I can simply have the application show a list of two or more products that match the regex and prompt the user to select the proper part. This, overall, will save time and mistakes in selecting a product type in the WMS database.

Thanks for the comments. I understand I’m not asking a question that has one answer to it. I’m looking for a starting point on how to best step through the string and spit out a corresponding Regex statement that would match the value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:07:48+00:00Added an answer on June 4, 2026 at 7:07 am

    As @Pete says, I think you have set yourself too ambitious a goal. Some thoughts, perhaps overly generalized from your specific needs.

    I take it that you want to scan a serial number like 1-56592-487-8 and infer that the regular expression /\d-\d{5}-\d{3}-\d/ matches parts of this type from a given manufacturer. (This happens to be the ISBN-10 for my copy of “Java in a Nutshell.” ISBNs are not serial numbers, but work with me.) But you can’t infer from a handful of examples what pattern the manufacturer uses. Maybe the first character position is a hex digit (0-F). Maybe the last character is a checksum that can be a digit or X (like ISBNs). Maybe there is a suffix, not always present, that denotes the plant. So you will find yourself building up many patterns for the same manufacturer/part type as new instances of the part come in.

    You will also have the reverse problem. A maker of widgets uses the regex /[A-Z]{3}\d{7}/, and a maker of sonic screwdrivers uses the same pattern.

    That said, about the best you can do is something this:

    for each character in the scanned serial number
        if it is a capital letter
            add [A-Z] to the regular expression
        else if it is a digit
            add \d to the regular expression
        else 
            add the character itself to the regular expression, escaped as necessary
     end for
     collapse multiple occurrences with the {,} interval qualifier
    

    The rules for Vehicle Identification Numbers may also be inspiring. Think about how you would infer the rules for VINs, given a handful of examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application written in PHP using MySQL that I would like
We have a web application written in PHP that exports MySQL query results to
I have a web application written in pure JavaScript (no pre-generated HTML except for
I have a web application written in PHP. It uses MySQL for data storage.
I have a web application, written in PHP, where we have a couple of
I have a web application, written in PHP, based on UTF-8 (both PHP and
I've written a layered web application that consists of a rich-web client (PHP) that
I have a Master - Slave setup for a web application written in PHP.
I have a web application written in PHP with many reports in HTML format.
I have a ticketing web application written with PHP and MySQL. I need something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.