Module:Str find word/doc: Difference between revisions

Content deleted Content added
...
 
(16 intermediate revisions by 2 users not shown)
Line 1:
{{Lua|Module:String|Module:TableTools|Module:Yesno}}
{{sandbox other
|1={{module:Str find word/links/doc}}
}}
Implements template '''{{tl|Str find word}}'''.
 
Line 8 ⟶ 5:
 
For example, in the source string '{{mono|1=foo, bar}}' the word '{{mono|1=bar}}' appears, but the word '{{mono|1=november}}' does not.
:<code><nowiki>{{#invoke:Str find word |main |source=foo, bar |word=bar}}</nowiki></code> <small>({{code|1=True}})</small> &rarr; {{#invoke:Str find word |main |source=foo, bar |word=bar}}
:<code><nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |word=november}}</nowiki></code> <small>({{code|1=False}})</small> &rarr; {{#invoke:Str find word |main |source=alpha, beta, gamma |word=november}}
 
''Multiple word check'': The search can be extended to check for multiple words being present.
 
''AND''-list of words, all words must be present:
:<code><nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |andwords=beta, alpha}}</nowiki></code> <small>({{code|1=True}})</small> &rarr; {{#invoke:Str find word |main |source=alpha, beta, gamma |andwords=beta, alpha}}
:<code><nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |andwords=beta, omega}}</nowiki></code> <small>({{code|1=False}})</small> &rarr; {{#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:
:<code><nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |orwords=beta, alpha}}</nowiki></code> <small>({{code|1=True}})</small> &rarr; {{#invoke:Str find word |main |source=alpha, beta, gamma |orwords=beta, alpha}}
:<code><nowiki>{{#invoke:Str find word |main |source=alpha, beta, gamma |orwords=beta, omega}}</nowiki></code> <small>({{code|1=False}})</small> &rarr; {{#invoke:Str find word |main |source=alpha, beta, gamma |orwords=beta, omega}}
 
Complete words: the complete word is '{{mono|1=foobar}}' (example needed)
Line 61 ⟶ 58:
| {{para|1=source|2=alpha, foo, lima}}
| {{para|word|foo}}
| {{#invoke:Str find word |main |explain=true |source=alpha, foo, lima |word=foo}}
| {{aye}}
|
Line 67 ⟶ 64:
| {{para|1=source|2=alpha, foo, lima}}
| {{para|word|bar}}
| {{#invoke:Str find word |main |explain=true |source=alpha, foo, lima |word=foo-bar}}
| {{nay}}
| full word ''bar'' not in the source
Line 73 ⟶ 70:
| {{para|1=source|2=alpha, foo, lima}}
| {{para|word|foobar}}
| {{#invoke:Str find word |main |explain=true |source=alpha, foo, lima}}
| {{nay}}
| word ''foobar'' not in the source as full word
|}
 
===AND-, OR-wordlist checks===
:{{para|word}} can be a ''list of words''. All will be checked with the ''AND''-requirement (each word must be present).
:{{para |andwords}} accepts a ''list of words'' that all will be checked with the ''AND''-requirement (each word must be present).
::WhenAlway, ''both'' {{para|word}}, and {{para |andwords}} are present, they are combined into one single ''AND''-wordlist.
 
:{{para |orwords}} accepts a ''list of words'' that all will be checked with the ''OR''-requirement (at least one of the words must be present).
{| class="wikitable" style=""
|-
! {{para|1=source}}<br/>{{para|1=s}}
! {{para|1=andwords}}<br/>{{para|1=word}}
! result
! note
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
| {{para |andw|delta, lima}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta, lima}}
| both words present in the source
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
| {{para |andw|foo, nov}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta}}
| AND-logic: A word in the ''AND''-list is not present ({{mono|nov}}), so false
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
| {{para |andw|delta}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta}}
| {{para|w}} and {{para |andw}} are combined
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
| {{para |andw|bar, april}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta}}
|
}|}
 
===OR-wordlist checks===
;{{para |orwords}}, {{para |orw}}
:{{para |orwords}} acceptsAccepts a ''list of words'' that all will be checked withby the ''OR''-requirement'' ("at least one of the words must be present).
 
{| class="wikitable" style=""
|-
! {{para|1=source}}<br/>{{para|1=s}}
!
! {{para|1=orwords}}
! result
! note
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
|
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta, lima}}
| both words present in the source
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
|
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta}}
|
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
| {{para |andw|delta}}
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta}}
| {{para|w}} and {{para |andw}} are combined
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
|
| {{para |orw|delta, lima}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |orw=delta, lima}}
| both OR-words are present in the source
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
|
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |orw=foo, nov}}
| OR-logic: one of the words is present ({{para|foo}}), so true
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
| {{para |andw|alpha, lima}}
| {{para |orw|foo, nov}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=alpha, lima |orw=foo, nov}}
|
|-
| {{para|1=s|2=alpha, foo, lima, delta}}
| {{para |andw|bar, april}}
| {{para |orw|nov, dec}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta |orw=nov, dec}}
| none of the OR-words is present, so false
|}
 
===both AND-words and OR-words to check===
;{{para |andwords}} {{para |orwords}}
:checks ''both'' lists for their own check: "ANd-words" must all be present, "OR-words" must have at least one present.
:Result: True if both check results are True, otherwise False.
 
{| class="wikitable" style=""
Line 95 ⟶ 179:
| {{para |andw|delta, lima}}
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta, lima}}
| both words present in the source
|-
Line 101 ⟶ 185:
| {{para |andw|foo, nov}}
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta}}
| AND-logic: A word in the ''AND''-list is not present ({{mono|nov}}), so false
|-
Line 107 ⟶ 191:
| {{para |andw|delta}}
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta}}
| {{para|w}} and {{para |andw}} are combined
|-
Line 113 ⟶ 197:
|
| {{para |orw|delta, lima}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |orw=delta, lima}}
| both OR-words are present in the source
|-
Line 119 ⟶ 203:
|
|
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |orw=foo, nov}}
| OR-logic: one of the words is present ({{para|foo}}), so true
|-
Line 125 ⟶ 209:
| {{para |andw|alpha, lima}}
| {{para |orw|foo, nov}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=alpha, lima |orw=foo, nov}}
|
|-
Line 131 ⟶ 215:
| {{para |andw|bar, april}}
| {{para |orw|nov, dec}}
| {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima, delta |andw=delta |orw=nov, dec}}
| none of the OR-words is present, so false
|}
Line 152 ⟶ 236:
| {{nay}}
|}
<noinclude>
==untested==
==untested; noinclude from main /doc==
:As of Mar 2023, not supported.
===casecasesensitive ===
:{{para|casesensitive|true}}, {{para|case|true}} Case-sensistive (A=/=a) DEFAULT
:{{para|casesensitive|false}}, {{para|case|false}} Not case-sensistive (A=a)
 
{| class="wikitable" style=""
|-
Line 166 ⟶ 254:
| {{para|w|foo}}
|
| &rarr; {{#invoke:Str find word |main |explain=true |s=alpha, foo, lima|w=foo|out-true=yes|out-false=no}}
|
|-
Line 172 ⟶ 260:
| {{para|w|foobar}}
|
| &rarr; {{#invoke:Str find word |main |explain=true |source=alpha, foo, lima |word=foobar|out-true=yes|out-false=no}}
|
|-
Line 178 ⟶ 266:
| {{para|w|foo}}
|
| &rarr; {{#invoke:Str find word |main |explain=true |source=alpha, foobar, lima |word=foo|out-true=yes|out-false=no}}
| 'foo' is not the complete word
|-
Line 184 ⟶ 272:
| {{para|w|foo}}
|
| &rarr; {{#invoke:Str find word |main |explain=true |source=alpha, FOO, lima |word=foo|out-true=yes|out-false=no|case=false}}
| {{para|case|false}}: a=A ''(default)''
|-
Line 190 ⟶ 278:
| {{para|w|foo}}
|
| &rarr; {{#invoke:Str find word |main |explain=true |source=alpha, FOO, lima |word=foo|out-true=yes|out-false=no|case=true}}
| {{para|case|true}}: a=/=A
|}
Line 197 ⟶ 285:
{| class="wikitable"
|-
! colspan="5" style="padding-left:3em; text-align:left;" | {{para|yesout-true|Yesout-true, a hit}}<br/>{{para|noout-false|Notout-falset found}}
|-
| {{para|1=source|2=alpha, foo, lima}}
| {{para|word|foo}}
| {{#invoke:Str find word |main |explain=true |source=alpha, foo, lima |word=foo|out-true=Yes, a hit|out-false=No, not found}}
| {{aye}}
|-
| {{para|1=source|2=alpha, foo, lima}}
| {{para|word|foobar}}
| {{#invoke:Str find word |main |explain=true |source=alpha, foo, lima |word=foobar|out-true=Yes, a hit|out-false=No, not found}}
| {{nay}}
|}
Line 237 ⟶ 325:
===synonyms===
:under construction
</noinclude>
 
==Errors and analysis==