Template:Str find word/doc

This template looks for a word in a comma-separated list of words. It returns a True (found) or False (not found) value.

By default, the True-value returned is the found word itself; the False-value is a blank string.
 * (True) &rarr;
 * (False) &rarr;

No partial fit. Partial word matching do not count as a hit:
 * (False) &rarr;

Case-sensitive: By default, the comparison is case-sensitive (Foo ≠ foo); all text is turned into lowercase. One can make the check case-sensitive by true
 * (True) &rarr;
 * (False) &rarr;

Using this template, the editor does not have to apply patterns ('%f[^,][^,]+%f[,]'). No return value interpretation is required (like when 1 then do x), though is optionally possible. There is no inbetween-result: the logic says it is either T or F. The logic can not result in an error.

options
The True and False return values can be set through yes, no:
 * (True) &rarr;
 * (False) &rarr;

Specifics

 * Words: A 'word' is the character string between commas. This can be all characters and inner spaces:
 * (True) &rarr;
 * (True) &rarr;


 * Return value: True- and False-value can be set through yes, no:
 * (True) &rarr;
 * (False) &rarr;


 * Boolean value read: Setting true will read common bolean words as boolean (true, false).
 * Boolean words for true: 'True', 'T', 'Yes', '1'. False: 'False', 'F', 'No', '0'. Boolean words are always case-insensistive (True=true).
 * (True) &rarr;
 * (True) &rarr;
 * (default) (False) &rarr;

Word lists
The word list source is comma-separated. Prefixed and suffixed spaces are discarded (trimmed).
 * Inner spaces are kept, and are part of the 'word':
 * Any character apart from $\langle,\rangle$ comma can be part of the word:
 * Any character apart from $\langle \rangle$ comma can be part of the word:
 * Any character apart from $\langle,\rangle$ comma can be part of the word:


 * Multiple spaces (whitespace) inside a string is reduced to a single space:


 * equals


 * Spaces $\langle"\rangle$, Comma $\langle|\rangle$, quote $\langle,\rangle$, pipe $\langle,\rangle$


 * Trimmed spaces: All words are trimmed before checking (leading and trailing whitespace is removed; repeated inner whitespaces are reduced to one space):
 * (True) &rarr;
 * ...but the remaining in-word space does matter:
 * (False) &rarr;


 * Comma $\langle"\rangle$: When a comma $\langle"\rangle$ is part of the word to check. Word strings that contain a comma can be made literal (escape the comma):
 * ❌   (True) &rarr;
 * ??chk:  (True) &rarr;
 * ??chk:  (True) &rarr;


 * Quote character $\langle|\rangle$: Conversely, quote characters ⇭⇭⇭ that are part of the word are escaped by setting false:
 * (True) &rarr;


 * Pipe ⇭⇭⇭: The pipe character can be entered as
 * (True) &rarr;

Checking multiple words
It is possible to check multiple words against the source wordlist.
 * AND-words to check
 * andwords: can have a wordlist (comma-separated as source is). Each word will be checked against the source. When all and-words are found, the return value is True.
 * (True) &rarr;
 * (True) &rarr;
 * (False) &rarr;


 * OR-words to check
 * orwords: can have a wordlist (comma-separated as source is). Each word will be checked against the source. When a single or-words is found, the return value is True. Default True return value is the list with all words found.
 * (True) &rarr;
 * (True) &rarr;
 * (False) &rarr;


 * Both AND-words, OR-words to check
 * andwords, :orwords can be used together. Each wordlist will get its own logical checks (AND-words must all be present; OR-words at least one)
 * T:  (True) &rarr;
 * (False) &rarr;

note

 * The editor does not have to apply Lua patterns like [%a%d]*
 * The editor does not have to interpret the return value (as in: "when ='blue' then ..."). They can prescribe the value even (yes-value, no-value).

Basic
Core function:


 * When the word is found in the source (True), the function returns the word itself (by default), or yes value (when entered non-empty).
 * When not found (False), the function returns an empty string (''), or the no value when entered.

All parameters

 * All parameters, in three options

word list

 * Instead of a single word to check, a list of target words can be entered: alpha, foo, bingo. This word-list will be treated with AND-logic: each and all of the words must be present. See:

AND-, OR-wordlist checks

 * word as noted, can be a list of words. all will be checked with the AND-requirement (each word must be present).
 * andwords accepts a list of words that all will be checked with the AND-requirement (each word must be present).
 * When both word, andwords are present, they are combined into one single AND-wordlist.
 * orwords accepts a list of words that all will be checked with the OR-requirement (at least one of the words must be present).

Errors and analysis

 * The logic itself does not produce errors. There is always a True of False result.


 * Pages with Unknown parameters are listed in.


 * 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).


 * true: when in, display a report on input, output and the logical steps (debug).
 * testcases: When set in ns Template or User on subpage /testcases, the Preview report is static (shown permanently).