Xbasic

WORD_SUBTRACT Function

Syntax

New_List as C = WORD_SUBTRACT(C Words, C Exclude_Words [,C Delimiter])

Arguments

WordsCharacter

The list of words or entries to examine.

Exclude_WordsCharacter

A CR-LF delimited list of word(s) to remove.

DelimiterCharacter

Default = whitespace (e.g. a space, tab, CR-LF). The character string that separates words or entries.

Returns

New_ListCharacter

Returns all words not included in the exclude list.

Description

Returns Words that are not in the exclude list.

Discussion

WORD_SUBTRACT() removes one or more words from a list of words or entries, ignoring case. The words to remove are specified as a CR-LF delimited list. WORD_SUBTRACT() is often used to remove one list of CR-LF delimited words from another list of CR-LF delimited words.

WORD_SUBTRACT() is case-insensitive. For case-sensitive comparisons, use WORD_SUBTRACTC().

dim list1 as c =<<%str%
one two three four
%str%

dim list2 as c =<<%str%
one
two
three
four
%str%

dim removelist as c =<<%str%
one
two
%str%

In the first case, the delimiter of list1 is assumed to be a whitespace character, and the words are removed. In the second case, the delimiter of list1 is specified to be CR-LF, so no words are removed.

? word_subtract(list1, removelist)
= three four

? word_subtract(list1, removelist, crlf() )
= one two three four

In both cases, the operation succeeds because list2 is delimited by CR-LF, which is a whitespace character.

? word_subtract(list2, removelist)
= three
four

? word_subtract(list2, removelist, crlf())
= three
four

See Also