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.
 * T:  &rarr;
 * F:  &rarr;

The True and False return values can be set through yes, no:
 * T:  &rarr;
 * F:  &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 its is either T or F. The logic can not result in an error.

Specifics

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


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


 * Partial fit: Partial word matching are not considered a hit:
 * F:  &rarr;


 * Case-sensitive: By default, the comparision is not case-sensitive (Foo = foo); all text is turned into lowercase. One can make the check case-sensitive by true
 * T:  &rarr;
 * F:  &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).
 * T:  &rarr;
 * T:  &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):
 * T:  &rarr;
 * ...but the remaining in-word space does matter:
 * F:  &rarr;


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


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


 * Pipe ⇭⇭⇭⇭⇭: The pipe character can be entered as
 * T:  &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.
 * T:  &rarr;
 * T:  &rarr;
 * F:  &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.
 * T:  &rarr;
 * T:  &rarr;
 * F:  &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:  &rarr;
 * F:  &rarr;

todo

 * words returned order
 * later
 * Note 1. The True return value is a list of all words found:
 * T:  &rarr;


 * later
 * Note 2. Parameter word is equal to andwords
 * alpha, foo
 * T:  &rarr;


 * orwords wordlist with OR-check: The wordlist orwords requires that at least one word of the list is found.
 * T:  &rarr;
 * Here too, all found words are returned in the True-value
 * T:  &rarr;


 * Checking AND-wordlists, OR-wordlists: andwords and orwords can be used together.
 * Words in the AND-list must all be present, the OR-list requires one or more words to be found.
 * When True, all hitwords are returned.
 * T:  &rarr;

note

 * The editor does not have to apply Lua patterns like [%a%d]*
 * The editor does not have to interpret the terurn value (as in: "when 0 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 a 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).