Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex creation based upon input
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>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.</p> <p>Anything in code is possible - is this feasible? </p> <hr> <p><strong>EDIT - ADDED SAMPLE VALUES</strong></p> <p>DVD-RW (Optical Drives)</p> <ul> <li>1613518L121</li> <li>1613509L121</li> <li>1613519L121</li> </ul> <p>VGA Output Cards</p> <ul> <li>0324311071068</li> <li>0324311071134</li> </ul> <p>COM Expansion Cards</p> <ul> <li>608131234</li> <li>608131237</li> </ul> <p>Hard Drives</p> <ul> <li>WMAYUJ753738</li> <li>WMAYUJ072099</li> <li>WMAYUJ683739</li> <li>WMAYUJ844900</li> </ul> <p>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.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload