I have multiple strings stored in my database called order number pattern. This pattern is dictated by the master user/company when setting up the application for themselves.
Therefore any user that creates an order from their company has to follow this pattern. The pattern set could be anything like '000000' or 'AAA00000' or 'AA00aaa000' and so on (mixture of numbers, upper case letters, lower case letters and special characters)
What I need to do is to validate that when an user enters the order number, it matches the pattern set by the company i.e. if the user enters BX12-xyz-345 then check that it matches pattern 'AA00-aaa-000'.
What I thought would be ideal is to generate a regex pattern based on the current pattern and store that against the customer record therefore it makes it easier for me to then match using Regex.match function. The only problem with this is that I have to manually create the regex patterns for each of our approx 250+ customers and therefore was wondering if there is way where I can pass in a string and it returns me a regex pattern for that string.
Ideally if I could do this in SQL server (vial bulk update) if not I do not mind creating a one time exe in C# that can go and update each record with its regex pattern and also change the application such that in future it only stores the regex pattern in the database.
^\d{6}$|^[A-Z]{3}-?\d{5}$|^[A-Z]{2}-?\d{2}-?[a-z]{3}-?\d{3}$This specific regex would check that the code is in the format000000,AAA-00000,AAA00000,AA00aaa000or evenAA-00-aaa-000orAA00-aaa-000, etc.