Product Site

5.1.7.38. caselessContainsWord

Returns .true if phrase is found in the receiving string. Returns .false if phrase contains no words or if phrase is not found. Word matches are made independent of case. Multiple whitespace characters between words in either phrase or the receiving string are treated as a single blank for the comparison, but, otherwise, the words must match, except for case.

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

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

Example 5.78. String class — caselessContainsWord method
good = "Now is the time for all good men"
good~caselessContainsWord("the")          -- .true
good~caselessContainsWord("The")          -- .true
good~caselessContainsWord("is the")       -- .true
good~caselessContainsWord("is   the ")    -- .true
good~caselessContainsWord("is time")      -- .false
good~caselessContainsWord("time")         -- .true
good~caselessContainsWord("time", 5)      -- .false