![]() | 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#find
- mw:Extension:Scribunto/Lua_reference_manual#Patterns
- User:DePiep/sfw
- User:DePiep/sfw/sandbox
This module is intended to find complete words in a string. For example, in the string 'alpha, foobar' the word 'alpha' appears, but the word 'foo' does not: there only is the word 'foobar'.
A word is defined to be consisting of: alphanumerics (a-z, A-Z, 0-9), the hyphen (-) and the underscore (_). For example: foobar, foo-bar, foo_bar, foo123, _foo, 12, -x. All other characters are non-word-characters (like: ', ; ( ) <space>').
The module is designed for template code usage. For example, your template has these parameter |format=
options, as input:
|format=bg-green, ucfirst, wikilink
Then you can handle formatting like this:
{{#invoke:sfw|main|string={{{format|}}}|word=bg-green|yes=<make bg green code>|no=<do nothing>}}
ucfirst, wikilink, bg-green|
Usage
{{#invoke:User:DePiep/sfw|function_name}}
parameters
{{#invoke|main|
|source =
|word =
|andwords =
|orwords =
|case =
|yes =
|no =
|dbg =
}}
{{#invoke|main|
|s =
|w =
|andw =
|orw =
|case =
|yes =
|no =
|dbg =
}}
{{#invoke|main|
|1 =
|2 =
|3 =
|4 =
|5 =
|6 =
|7 =
|8 =
}}