This template is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Templates remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure.
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: {{Str find word |source=alpha, foo, bar |word=foo}} → foo
F: {{Str find word |source=alpha, foo, bar |word=nov}} →
The True and False return values can be set through |yes=, |no=:
T: {{Str find word |source=alpha, foo, bar |word=foo |yes=Yesss |no=Nooo}} → Yesss
F: {{Str find word |source=alpha, foo, bar |word=nov |yes=Yesss |no=Nooo}} → Nooo
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.
Specifics
Words
A 'word' is the character string between commas. This can be all characters and inner spaces:
T: {{Str find word |source=alpha, foo bar sunday, bar |word=foo bar sunday}} → foo bar sunday
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: {{Str find word |source=alpha, beta, gamma, foo, bar |andwords=alpha, foo}} → alpha,foo
T: {{Str find word |source=alpha, beta, gamma, foo, bar |andwords=bar, foo, beta, alpha}} → bar,foo,beta,alpha
F: {{Str find word |source=alpha, beta, gamma, foo, bar |andwords=alpha, nov}} →
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: {{Str find word |source=alpha, beta, gamma, foo, bar |orwords=alpha, foo}} → alpha
T: {{Str find word |source=alpha, happy, gamma, nice, foo, bar |orwords=april, sad, happy, ugly, nice}} → happy,nice
F: {{Str find word |source=alpha, happy, gamma, nice, foo, bar |orwords=sad, ugly, november}} →
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: {{Str find word |source=alpha, beta, april, gamma, foo, happy |andwords=alpha, beta |orwords=april, november, sad, ugly}} → alpha,beta,april
F: {{Str find word |source=alpha, beta, april, gamma, foo, happy |andwords=alpha, november |orwords=april, november, sad, ugly}} →
todo
word order in return string
resove synonyms eg |_monday=Monday, Mon, monday
Note 1. The True return value is a list of all words found
T: {{Str find word |source=alpha, beta, gamma, foo, bar |andwords=alpha, foo}} → alpha,foo
Instead of a single word to check, a list of target words can be entered: |word=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.