I think the best way to do it will be to compare the characters in reverse and succeed if it matches most part of the number. To decide on what is most part, is dependent on the application you develop. I guess this is how the caller ID's too work.