Module:Str find word/links/doc
This module depends on the following other modules:
Implements {{ Str find word }} .
This module looks for a full word in a comma-separated list of words. It then returns a True or False value.
By default, the True-value returned is the found word itself; the False-value is a blank string.
The search can be extended to check for multiple words being present.
For example, in the string 'alpha, foobar ' the word 'alpha ' appears, but the word 'foo ' does not: there only is the complete word 'foobar '. The module is aimed at template code usage. (The editor does not have to apply Lua patterns like [%a%d]*
) .
Usage
This documentation is not updated yet . May be wrong in situiations. Soo also the tempalte documentation at {{ Str find word }}
Basic
Core function:
{{Str find word
|source =
|word =
|yes =
|no =
}}
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.
|source=
|word=
result
note
|source=alpha, foo, lima
|word=foo
foo
Y
|source=alpha, uc-all
|word=uc-all
uc-all
Y
|source=alpha, hello world_, bar
|word=hello world_
hello world_
Y
the comma is the word-delimiter
|source=alpha, hello world_, bar
|word=hello world_
hello world_
Y
The comma is the word-delimiter
|source=alpha,foo bar , lima
|word= foo bar
foo bar
Y
Spaces are trimmed, multi-space into one space
|source=alpha, FOO, bAr, lima
|word=bAr, FOO
bAr,FOO
Y
Not case-sensistive by default
|source=alpha, FOO, bAr, lima
|word=bAr, FOO
bAr,FOO
Y
|case=true
: case-sensistive
|source=alpha, foo, lima
|word=
N
no |word=
entered
|source=alpha, foo, lima
|word=foobar
No, not found
N
full word foo-bar not in the source
|source=alpha, foo, lima
|word=foobar
No, not found
N
word foo not in the source as full word
...
|yes=Yes, hit
|no=Not found
|source=alpha, foo, lima
|word=foo
Yes, hit
Y
|source=alpha, foo, lima
|word=foobar
No, not found
N
All parameters
All parameters, in three options
{{Str find word
|string =
|word =
|allwords =
|orwords =
|case=
|yes =
|no =
|explain =
}}
{{Str find word
|s =
|w =
|allw=
|orw =
|case=
|yes =
|no =
|explain =
}}
{{Str find word |s= |w= |allw= |orw= |case= |yes= |no= |explain=}}
More options
|source=
|s=
|word=
|w=
|case=
result
note
|s=alpha, foo, lima
|w=foo
yes
|s=alpha, foo, lima
|w=foobar
no
|s=alpha, foobar, lima
|w=foo
no
'foo' is not the complete word
|s=alpha, FOO, lima
|w=foo
yes
|case=false
: a=A (default)
|s=alpha, FOO, lima
|w=foo
no
|case=true
: a=/=A
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).
|source=
|s=
|andwords=
|andw=
|orwords=
|orw=
result TODO fix
note
|s=alpha, foo, lima, delta
|andw=delta, lima
delta,lima
both words present in the source
|s=alpha, foo, lima, delta
|andw=foo, nov
AND-logic: A word in the AND -list is not present (nov ), so false
|s=alpha, foo, lima, delta
|andw=delta
delta
|w=
and |andw=
are combined
|s=alpha, foo, lima, delta
|orw=delta, lima
delta,lima
both OR-words are present in the source
|s=alpha, foo, lima, delta
foo
OR-logic: one of the words is present (|foo=
), so true
|s=alpha, foo, lima, delta
|andw=alpha, lima
|orw=foo, nov
alpha,lima,foo
|s=alpha, foo, lima, delta
|andw=bar, april
|orw=nov, dec
none of the OR-words is present, so false
Errors and analysis
The logic itself does not produce errors. There is always a True of False result.
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).
|explain=true
: when in Preview , display a report on input, output and the logical steps (debug).
|explain=testcases
: When set in ns Template or User on subpage /testcases , the Preview report is static (shown permanently).