|
-
Jan 11th, 2006, 09:42 AM
#1
[RESOLVED] string comparison function
Does anyone happen to have a function available with the following functionality:
Input: 2 strings
Output: long
The function should compare the two strings, and return the number of characters that are the same.
example 1:
string 1: "123456789012345"
string 2: "023456789012345"
Return value: 14
This was an easy one, and I have no problem writing a function that does that. The problem is, that I want it to be able to recognize patterns that are the same like in the next example.
example 2:
string 1: "123456789012345"
string 2: "234567890123450"
return value: 14
I marked the characters that are identical in red:
123456789012345
234567890123450
The purpose of the function is comparing IMEI numbers (an id for mobile phones).
These imei numbers are always numerical, and have 15 characters.
I want to find out if the number entered by the customer (when he entered the order on the website), is identical to the number that was on the phone.
If the numbers are not identical, it could be that the customer made a typo (switched two numbers, or forgot a number, and typed a fake number at the end), or that the number belongs to a different phone.
I want to handle these situations differently, so if the numbers match partialy (say 12 characters match), I guess the customer made a typo.
P.S. I know IMEI numbers must pass a luhn check, but there are reasons I don't want to check this at order entry (at least not right now).
The
Last edited by Frans C; Jan 12th, 2006 at 04:26 AM.
Frans
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|