## Compare Text Test

This function is used to compare two text strings. The source string may be a track's field or a named variable. The compare against field can be a specified text pattern, the contents of a named variable or the contents of a track's variable field.

When specifying named variables or a text pattern you may use any of the escape sequences described in Escape Sequences.

The function can test if the source and against strings are equal, if the source contains the against text, if the source starts or ends with the against text, if the source is like the against text, do a variety of relational tests or do a fuzzy comparison.

You can specify that the test should ignore alphabetic case and you may negate the result of the test.

When testing for contains, starts with or ends with you can specify Match words. In this mode you match whole words only. For the purposes of this function a match whole word test fails if:

> the first character in the from pattern is alphanumeric and the character preceding the match is alphanumeric.
> or if:
> the last character in the from pattern is alphanumeric and the character following the match is alphanumeric.

When testing for like, the character * will match 0 or more characters and ? will match exactly 1 character. Unlike the starts, ends and contains tests, like must specify a pattern to match the entire field.Unless you want your test to be anchored at the end of the against text, you might need a trailing *. If you have an expression too complicated for the like test, you can always use the Regular Expression Replace statement, ignoring the replacement and simply using the resultant action test state.

The fuzzy test uses Yate's fuzzy comparison logic to compare the two text strings. Various factors are used in a fuzzy comparison. Regardless of the value of the case insensitive option, the test always ignores alphabetic case, punctuation characters, diacritical marks and Unicode width differences. The Weight Exception Set is used to determine a set of words to be ignored. A fuzzy test returns a percentage representing the success of the comparison. By default this function returns a true value for a success of 80 or higher. You can change the threshold of the test by setting the named variable fuzzy threshold to an integer value in the range of 1-100.

The fuzzy test can be further configured to ignore the position of words when comparing. To force non positional testing, set the named variable fuzzy threshold to a negative number in the range of -1 to -100. The actual threshold used is the absolute value of the specified number. Using a negative threshold will result in a comparison of "John and Bill" being a 100% match to "Bill and John".

If the named variable fuzzy threshold is set to a value less than -100, 0, or greater than 100, the default of 80 will be used.

In order that you can determine which threshold values make sense for you, the fuzzy test always stores the actual result as an integer, in the range of 0-100, to the named variable fuzzy %.

If you specify a result of Set, the action's test state will be set to True or False depending on the result of the test. If you specify a result of And, the action's test state will be set to false if the result of the test is false. If you specify result of Or, the action's test state will be set to true is the result of the test is true.

In stepwise execution mode the following holds: If the source is a named variable, the compare function is only performed once. If the source is a not a named variable the compare function is interpreted as for all files unless the Any option is selected.