![]() | This is a documentation subpage for Module:Str find word. It may contain usage information, categories and other content that is not part of the original module page. |
- Module:String · {{Navbox wikitext-handling templates}} · Module:TableTools · Module:If preview
- mw:Lua manual · User:DePiep/sfw (/sandbox)
- Is preview: Script error: No such module "User:DePiep/sfw".
- ====unicode html decode====
- T Script error: No such module "User:DePiep/sfw".
- T Script error: No such module "User:DePiep/sfw".
- T Script error: No such module "User:DePiep/sfw".
- T Script error: No such module "User:DePiep/sfw".
- f Script error: No such module "User:DePiep/sfw".
- ====basic tests====
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
yes no options
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
non-text output
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
E0x input
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
- Script error: No such module "User:DePiep/sfw".
{Module rating|pre-alpha}}
This module is intended to find complete words in a string. It returns a True or False value, which can be used accordingly. 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]*
).
A word is defined to be only of these characters: alphanumerics ('a-z A-Z 0-9'), hyphen ('-') and underscore ('_') . All other characters are non-word characters, and so possible word-separators (like ';,()<space>'
12px ).
- Word examples todo check+good examples
- foo, foobar, foo-bar foo_bar#)($foo123 Foo. FOO..._foo] 12, -x, zob(28)
- foo, foobar, foo-bar foo_bar#)($foo123 Foo. FOO..._foo] [12, -x
- foo, foobar, foo-bar foo_bar#)($foo123 Foo. FOO..._foo] [12, -x
For example: your template can use your predefined options as single parameter |format=
input:
|format=bg-green, uc_first, wikilink
The template then can handle formatting like this:
{{#invoke:sfw|main|source={{{format|}}}|word=bg-green |yes=<make bg green code> |no=<do nothing>}}
{{#invoke:sfw|main|source={{{format|}}}|word=uc_first |yes=<set uc first code> |no=<do nothing>}}
Or, using the default output:
{{#if:{{#invoke:sfw|main|source={{{format|}}}|word=bg-green}} |<make bg green code> |<do nothing>}}
{{#if:{{#invoke:sfw|main|source={{{format|}}}|word=uc_first}} |<set uc first code> |<do nothing>}}
Usage
Basic
Core function:
{{User:DePiep/sfw |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
|
Script error: No such module "User:DePiep/sfw". | ||
|source=alpha, uc-all
|
|word=uc-all
|
Script error: No such module "User:DePiep/sfw". | "-" (hyphen) is part of the word | |
|source=alpha, do_something, white
|
|word=do_something
|
Script error: No such module "User:DePiep/sfw". | "_" (underscore) is part of the word | |
|source=alpha, foo, lima
|
|word=november
|
Script error: No such module "User:DePiep/sfw". | ||
|source=alpha, foobar, lima
|
|word=foo
|
Script error: No such module "User:DePiep/sfw". | 'foo' is not the complete word | |
|source=alpha, foo, lima
|
|word=
|
Script error: No such module "User:DePiep/sfw". | no |word= entered
| |
|source=alpha, foo, lima
|
|word=foobar
|
Script error: No such module "User:DePiep/sfw". | full word foo-bar not in the source | |
|source=alpha, foo, lima
|
|word=foobar
|
Script error: No such module "User:DePiep/sfw". | word foo not in the source as full word | |
... |yes=Yes, hit |no=Not found
| ||||
|source=alpha, foo, lima
|
|word=foo
|
Script error: No such module "User:DePiep/sfw". | ||
|source=alpha, foo, lima
|
|word=foobar
|
Script error: No such module "User:DePiep/sfw". |
All parameters
- All parameters, in three options
{{User:DePiep/sfw |string = |word = |allwords = |orwords = |case= |yes = |no = }} |
{{User:DePiep/sfw |s = |w = |allw= |orw = |case= |yes = |no = }} |
{{User:DePiep/sfw | = | = |allw= |orw = |case= |yes = |no = }} |
{{User:DePiep/sfw |s= |w= |allw= |orw= |case= |yes= |no= }}
More options
|source= |s= |1=
|
|word= |w= |2=
|
|case=
|
result | note | |
---|---|---|---|---|---|
|s=alpha, foo, lima
|
|w=foo
|
Script error: No such module "User:DePiep/sfw". | |||
|s=alpha, foo, lima
|
|w=foobar
|
Script error: No such module "User:DePiep/sfw". | |||
|s=alpha, foobar, lima
|
|w=foo
|
Script error: No such module "User:DePiep/sfw". | 'foo' is not the complete word | ||
|s=alpha, FOO, lima
|
|w=foo
|
Script error: No such module "User:DePiep/sfw". | |case=false : a=A (default)
| ||
|s=alpha, FOO, lima
|
|w=foo
|
Script error: No such module "User:DePiep/sfw". | |case=true : a=/=A
|
word list
- 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: - Wordlist examples:
|word=(wordlist)
|word=alpha, foo
|word=alpha-beta; _bar;all-up#foo(27) Oct Nov [Dec]
- When
|word=
contains a wordlist, all words must be present to return the Yes value (AND-logic).
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.
- When both
|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
|
Script error: No such module "User:DePiep/sfw". | both words present in the source | |
|s=alpha, foo, lima, delta
|
|andw=foo, nov
|
Script error: No such module "User:DePiep/sfw". | AND-logic: A word in the AND-list is not present (nov), so false | |
|s=alpha, foo, lima, delta
|
|andw=delta
|
Script error: No such module "User:DePiep/sfw". | |w= and |andw= are combined
| |
|s=alpha, foo, lima, delta
|
|orw=delta, lima
|
Script error: No such module "User:DePiep/sfw". | both OR-words are present in the source | |
|s=alpha, foo, lima, delta
|
Script error: No such module "User:DePiep/sfw". | OR-logic: one of the words is present (|foo= ), so true
| ||
|s=alpha, foo, lima, delta
|
|andw=alpha, lima
|
|orw=foo, nov
|
Script error: No such module "User:DePiep/sfw". | |
|s=alpha, foo, lima, delta
|
|andw=bar, april
|
|orw=nov, dec
|
Script error: No such module "User:DePiep/sfw". | none of the OR-words is present, so false |
Roundup
- A word can be a-z, A-Z, 0-9, - _ (not: ;,=()[]#$%)
- Absent words never can make a positive
- All
|word=foo, bar
words are treated as AND- words (equally to, and together with|andwords=
) - AND-word must all be present in the source
- OR-words require that at least one is present in the source
|yes=
cannot be empty (a True result will return either your|yes=vaue
or, by default, the yes-words found- There are no "error" results. If anything fails, it's a No.
errors and analysis
- Pages with Unknown parameters are listed in Category:Unknown parameters (302) (todo)
- 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).