Product Site

5.4.11.18. containsWord

Returns .true if phrase is found in the receiving buffer. Returns .false if phrase contains no words or if phrase is not found. Multiple whitespace characters between words in either phrase or the receiving buffer are treated as a single blank for the comparison, but, otherwise, the words must match exactly.

By default the search starts at the first word in the receiving buffer. You can override this by specifying start (which must be positive whole number), the word at which the search is to be started.

See also methods caselessContainsWord and wordPos (containsWord returns .false exactly if wordPos would have returned 0.)

Example 5.268. MutableBuffer class — containsWord method
good = .MutableBuffer~new("Now is the time for all good men")
good~containsWord("the")          -- .true
good~containsWord("The")          -- .false
good~containsWord("is the")       -- .true
good~containsWord("is   the ")    -- .true
good~containsWord("is time")      -- .false
good~containsWord("time")         -- .true
good~containsWord("time", 5)      -- .false