Data in the DB: Various users are putting data into my application (as a string from different areas), this data is stored in [SerialID#] DB column
. Contents are for e.g. barcode numbers, serial numbers etc.
Edit: Datasearched, Later another user returns and searches for the same product, but enter his search sub/string with/out the chars.
While doing my search user entered string
against the [SerialID#] DB column
, I need the alphanumeric content to match. (by stripping out the additional chars in between in both the DB/target and the user string/source).
I have to do this because, some vendors A's serial is different from Vendor B's serial I am unable to control how the user puts data into my app.
I need help in searching the string for only the following two scenarios both in SQL server and on the .NET serverside.
For e.g
B ABCLKSAL1930239923-938 2998/84
== Match ABClksAL1930239923938299884
Given a source and target string like a barcode/serial with dashes/hyphen;
- How can I match the contents alone, ignoring the hypens, slashes, spaces
-
/ \
or?
- How can I match numbers only? (i.e. digits only)
- How can I match the contents after the 3 characters BMS8937-932093 == 8937932093
- would be nice if this can this be parametrized to a function where it can be reused, [with passing, a) number of first or last characters to ignore b) match digits only vs alphanumberic only c) specificy the length to truncate]
I tried this [A-Za-z0-9]
but was not able to figure out how to match the contents per 1, 2 and 3.