Hi all. I've got a problem here, and I am not at all sure how I should be approaching it.
What I have is a whole load of defined formats for specific data types. For example:
^\d{2}.\d{2}.\d{2}$ date ^\d{2}.\d{2}.\d{4}$ date ^[A-Z]{2}\d{9}[A-Z]{2}$ Royal Mail Track & Trace code ^\d{16}$ visa card ^\d{13}$ EAN-13 barcode ...
What I want to do is to pass a string into a subroutine, where the string is compared to the definition list, and to return a value indicating what the string is, or represents. Obviously, the list above is very simplistic, as not every 13 digit number will be a valid barcode -- so there will be additional checks performed if it matches, so that it will also recognise and differentiate between subtypes (ISBN numbers, for example).
What I would like to know is how I should be doing this whilst ensuring that it is reasonably fast and efficient. Help would be very much appreciated.
In reply to Pattern Identification by WhiteTraveller
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |