Module:Str find word/doc explained

Implements template .

This module looks for a word being present in a comma-separated list of words. It then returns a or value. By default, the True-value returned is the found word itself; the False-value is a blank string.

For example, in the source string '' the word '' appears, but the word '' does not.

<nowiki>{{#invoke:Str find word |main |source=foo, bar |word=bar}}</nowiki>

<nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |word=november}}</nowiki>

Multiple word check: The search can be extended to check for multiple words being present.

AND-list of words, all words must be present:

<nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |andwords=beta, alpha}}</nowiki>

<nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |andwords=beta, omega}}</nowiki>

OR-list of words, at least one off the words must be present:

<nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |orwords=beta, alpha}}</nowiki>

<nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |orwords=beta, omega}}</nowiki>

Complete words: the complete word is '' (example needed)Whitespace is trimmed,

The module is aimed at template code usage. (The editor does not have to apply Lua patterns like).}}

Parameters

Main parameters (including their synonyms)

{{Str find word
|source= s=
 |word= andwords= andw=
 |orwords= orw=
|case=
|out-true=
|out-false=
}}
{{Str find word |s= |w= |andw= |orw= |case= |out-true= |out-false=}}

Basic: word is in source-wordlist?

{{Str find word
|source =
|word   =
}}

<nowiki>{{Str find word |source=cow, horse, dog, fish |word=dog}}</nowiki>

<nowiki>{{Str find word |source=cow, horse, dog, fish |word=cat}}</nowiki>

True/False return value

When the word is found in the source (True), the function returns the word itself (by default), or value (when entered non-empty).

When not found (False), the function returns a empty string, or the value when entered.

full word bar not in the source
word foobar not in the source as full word

AND-wordlist checks

can be a list of words. All will be checked with the AND-requirement (each word must be present).

accepts a list of words that all will be checked with the AND-requirement (each word must be present).

Alway, both and are combined into one single AND-wordlist.



result note
both words present in the source
AND-logic: A word in the AND-list is not present, so false
and are combined

OR-wordlist checks

,
  • Accepts a list of words that all will be checked by the OR-requirement ("at least one of the words must be present).

    result note
    both words present in the source
    and are combined
    both OR-words are present in the source
    OR-logic: one of the words is present, so true
    none of the OR-words is present, so false

    both AND-words and OR-words to check

    checks both lists for their own check: "ANd-words" must all be present, "OR-words" must have at least one present.
  • Result: True if both check results are True, otherwise False.


    result note
    both words present in the source
    AND-logic: A word in the AND-list is not present, so false
    and are combined
    both OR-words are present in the source
    OR-logic: one of the words is present, so true
    none of the OR-words is present, so false

    Edge cases

    Blank list(s)
  • Empty input string(s) will conclude negative:

    untested; noinclude from main /doc

    As of Mar 2023, not supported.

    casesensitive

    , Case-sensistive (A=/=a) DEFAULT

    , Not case-sensistive (A=a)



    resultnote
    'foo' is not the complete word

    a=A (default)

    a=/=A

    boolean words

    will convert all boolean words into "True/False".
  • per (= true) (todo: document value 2?, nil, blanketc. Irrespective of case?)
  • other words not changed ("horse" remains horse, not T/F).
  • Note: per logic definition, the word "false" is returned (as being found).

    quotes, escape

    under construction

    synonyms

    under construction

    Errors and analysis

    There are no logical errors foreseen: any flaw in the input will return a False result (for example, no input strings to check were entered).