Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Str find word/doc
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
:TOC: [[#code]] ({{edit|Module:Str find word}}) {{Module:Str find word/links/doc}} {{Module rating|pre-alpha}} {{Lua|Module:Yesno|Module:TableTools|Module:String}} This module looks for a word being present in a comma-separated list of words. It then returns a {{code|True}} or {{code|False}} value. By default, the True-value returned is the found word itself; the False-value is a blank string. Implements {{tl|Str find word}}. For example, in the source string '{{mono|1=foo, bar}}' the word '{{mono|1=bar}}' appears, but the word '{{mono|1=november}}' does not. :True: <code><nowiki>{{#invoke:Str find word|main |source=foo, bar|word=bar}}</nowiki></code> → >{{#invoke:Str find word|main |source=foo, bar|word=bar}}< :False: <code><nowiki>{{#invoke:Str find word|main |source=alpha, beta, gamma|word=november}}</nowiki></code> → >{{#invoke:Str find word|main |source=alpha, beta, gamma|word=november}}< Complete words: the complete word is '{{mono|1=foobar}}' ... example needed ... ''Multiple word check'': The search can be extended to check for multiple words being present. ''AND''-list of words, all words must be present: :True: <code><nowiki>{{#invoke:Str find word|main |source=alpha, beta, gamma|andwords=beta, alpha}}</nowiki></code> → >{{#invoke:Str find word|main |source=alpha, beta, gamma|andwords=beta, alpha}}< :False: <code><nowiki>{{#invoke:Str find word|main |source=alpha, beta, gamma|andwords=beta, omega}}</nowiki></code> → >{{#invoke:Str find word|main |source=alpha, beta, gamma|andwords=beta, omega}}< ''OR''-list of words, at least one off the words must be present: :True: <code><nowiki>{{#invoke:Str find word|main |source=alpha, beta, gamma|orwords=beta, alpha}}</nowiki></code> → >{{#invoke:Str find word|main |source=alpha, beta, gamma|orwords=beta, alpha}}< :False: <code><nowiki>{{#invoke:Str find word|main |source=alpha, beta, gamma|orwords=beta, omega}}</nowiki></code> → >{{#invoke:Str find word|main |source=alpha, beta, gamma|orwords=beta, omega}}< The module is aimed at template code usage. <small>(The editor does not have to apply Lua patterns like {{code|1=[%a%d]*}})</small>.
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)