I need to be able to determine whether or not a particular piece of text inside a text field on my form is a ProductId.
I think I may (regrettably) need Regex for this.
Anyway, there could be any number of possible things inside a search query, and I need to determine the likeliness of something inside the field being a productid.
All our product Id’s are of the following format:
AA8678NY
ONO23476
OPI765.0987
And there doesn’t seem to be any common format (there are over 400, 000 product id’s in the database).
So basically, I guess what I’m trying to say is that any product id can be thought of as starting with either 1 or more numbers, or letters, followed by either 1 dot or 1 or more numbers or letters, and ending with either 1 or more letters or numbers. – And sometimes it’s just a bunch of numbers.
Can we achieve something like this without regex?
Any help at all is appreciated.
You can, but why would you?
The Regex is actually very simple:
If there is a known minimum length, replace
+with{n,}