ABBREV - check for valid abbreviation.

ABBrev (S1, S2) returns I

checks to see if S2 is a valid abbreviation of the pattern S1. The value returned is an indicator of how well S2 matches S1.

The pattern string S1 indicates an abbreviation pattern. Characters which must appear in valid abbreviations should be given in upper case; other characters which can appear in abbreviations should be given in lower case. All non-alphabetic characters except '_' in S1 must be matched for a valid abbreviation.

A valid abbreviation S2 a string containing all the necessary (upper case) characters in the correct order; other (lower case) characters in the pattern may appear in the abbreviation, but characters which are not in the "pattern" may not appear. ABBrev ignores the case of characters in S2.

ABBrev returns a negative number if S2 is not a valid abbreviation for S1. If S2 is a valid abbreviation, ABBrev returns an integer score indicating how good the abbreviation is. The score gives one point for each lower case character matched. The score function gives 1024 points for each upper case or non-alphabetic character matched. For the pattern "eXtract" (note the upper and lower cases) the following results would be obtained.

string      score
"x"         1024
"ex"        1025
"extr"      1027
"extrat"    1029
"xtrt"      1027
"extract"   1030
"e"         -1
"tract"     -1
"xtray"     -1

Copyright © 1996, Thinkage Ltd.