This template is rated as alpha. It is ready for third party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
This template uses Lua: |
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.
{{Str find word |source=alpha, foo, bar |word=foo}}
(True
) → foo{{Str find word |source=alpha, foo, bar |word=nov}}
(False
) →No partial fit. Partial word matching do not count as a hit:
{{Str find word |source=alpha, foobar, bar |word=foo}}
(False
) →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 |case=true
{{Str find word |source=alpha, Foo, bar |word=foo |case=false}}
(True
) → foo{{Str find word |source=alpha, Foo, bar |word=foo |case=true}}
(False
) →
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.
The True and False return values can be set through |yes=
, |no=
:
{{Str find word |source=alpha, foo, bar |word=foo |yes=Yesss |no=Nooo}}
(True
) → Yesss{{Str find word |source=alpha, foo, bar |word=nov |yes=Yesss |no=Nooo}}
(False
) → Nooo{{Str find word |source=alpha, foo bar sunday, bar |word=foo bar sunday}}
(True
) → foo bar sunday{{Str find word |source=alpha, bar(22) [take care]!, foo |word=bar(22) [take care]!}}
(True
) → bar(22) [take care]!|yes=
, |no=
:{{Str find word |source=alpha, foo, bar |word=foo |yes=Yesss |no=Nooo}}
(True
) → Yesss{{Str find word |source=alpha, foo, bar |word=nov |yes=Yesss |no=Nooo}}
(False
) → Nooo|booleans=true
will read common bolean words as boolean (true, false).{{Str find word |source=alpha, yes, bar |word=true |booleans=true}}
(True
) → true{{Str find word |source=alpha, false, bar |word=0 |booleans=true}}
(True
) → false{{Str find word |source=alpha, false, bar |word=0 |booleans=false}}
(default) (False
) → The word list |source=
is comma-separated. Prefixed and suffixed spaces are discarded (trimmed).
{{Str find word |source=alpha , hello world, foo |word=hello world}}
(True
) → hello world
{{Str find word |source=alpha, hello world, foo |word=helloworld}}
(False
) →
{{Str find word |source=alpha, "hello, world", foo |word="hello, world"}}
(True
) → "hello,world"{{Str find word |source=alpha, "hello, world", foo |word="hello, world"|literals=false}}
(True
) → "hello,world"{{Str find word |source=alpha, "hello, world", foo |word="hello, world"|literals=true}}
(True
) → "hello,world"|literals=false
:{{Str find word |source=alpha, she said "hello world", "foo" |word=she said "hello world" |literals=false}}
(True
) → she said "hello world"{{!}}
{{Str find word |source=alpha, hello{{!}}world, foo |word=hello{{!}}world }}
(True
) → hello|worldIt is possible to check multiple words against the source wordlist.
|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.{{Str find word |source=alpha, beta, gamma, foo, bar |andwords=alpha, foo}}
(True
) → alpha,foo{{Str find word |source=alpha, beta, gamma, foo, bar |andwords=bar, foo, beta, alpha}}
(True
) → bar,foo,beta,alpha{{Str find word |source=alpha, beta, gamma, foo, bar |andwords=alpha, nov}}
(False
) →|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.{{Str find word |source=alpha, beta, gamma, foo, bar |orwords=alpha, foo}}
(True
) → alpha{{Str find word |source=alpha, happy, gamma, nice, foo, bar |orwords=april, sad, happy, ugly, nice}}
(True
) → happy,nice{{Str find word |source=alpha, happy, gamma, nice, foo, bar |orwords=sad, ugly, november}}
(False
) →|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){{Str find word |source=alpha, beta, april, gamma, foo, happy |andwords=alpha, beta |orwords=april, november, sad, ugly}}
(True
) → alpha,beta,april{{Str find word |source=alpha, beta, april, gamma, foo, happy |andwords=alpha, november |orwords=april, november, sad, ugly}}
(False
) →|source=
|
|word=
|
result | note | |
---|---|---|---|---|
|source=alpha, foo, lima
|
|word=foo
|
foo | ||
|source=alpha, foo, lima
|
|word=nov
|
|||
|source=alpha, uc-all
|
|word=uc-all
|
uc-all | ||
|source=alpha, hello world_, bar
|
|word=hello world_
|
hello world_ | The comma is the word-delimiter | |
|source=alpha,foo bar , lima
|
|word= foo bar
|
foo bar | Spaces are trimmed, multi-space into one space | |
|source=alpha, foo bar, lima
|
|word=foobar
|
An inner space is a character too | ||
|source=alpha, FOO, bAr, lima
|
|word=bar, foo
|
Not case-sensistive by default | ||
|source=alpha, FOO, bAr, lima
|
|word=bar, foo
|
|case=true : case-sensistive
|
[%a%d]*
Core function:
{{Str find word
|source =
|word =
|yes =
|no =
}}
|yes=
value (when entered non-empty).''
), or the |no=
value when entered.|source=
|
|word=
|
result | note | |
---|---|---|---|---|
|source=alpha, foo, lima
|
|word=foo
|
foo | ||
|source=alpha, uc-all
|
|word=uc-all
|
uc-all | "-" (hyphen) is part of the word | |
|source=alpha, do_something, white
|
|word=do_something
|
do_something | "_" (underscore) is part of the word | |
|source=alpha, foo, lima
|
|word=november
|
|||
|source=alpha, foobar, lima
|
|word=foo
|
'foo' is not the complete word | ||
|source=alpha, foo, lima
|
|word=
|
no |word= entered
| ||
|source=alpha, foo, lima
|
|word=foobar
|
No, not found | full word foo-bar not in the source | |
|source=alpha, foo, lima
|
|word=foobar
|
No, not found | word foo not in the source as full word | |
... |yes=Yes, hit |no=Not found
| ||||
|source=alpha, foo, lima
|
|word=foo
|
Yes, hit | ||
|source=alpha, foo, lima
|
|word=foobar
|
No, not found |
{{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=}}
|source= |s= |1=
|
|word= |w= |2=
|
|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
|
|word=alpha, foo, bingo
. This |word=
-list will be treated with AND-logic: each and all of the words must be present. See:|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).
|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).|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).