# வார்ப்புரு:Str find word/doc



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: <code></code> &rarr;  
:F: <code></code> &rarr;  

The True and False return values can be set through , :  
:T: <code></code> &rarr;  
:F: <code></code> &rarr;  

Using this template, the editor does not have to apply patterns . No return value interpretation is required (like ), 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: <code></code> &rarr;  
:T: <code></code> &rarr;  

;Return value: True- and False-value can be set through , :  
:T: <code></code> &rarr;  
:F: <code></code> &rarr;  

;Partial fit: Partial word matching are *not* considered a hit:  
:F: <code></code> &rarr;  

;Case-sensitive: By default, the comparison is *not* case-sensitive ; all text is turned into lowercase. One can make the check case-sensitive by  
:T: <code></code> &rarr;  
:F: <code></code> &rarr;  

;Boolean value read: Setting will read common *bolean words* as boolean (true, false).  
:Boolean words for true: 'True', 'T', 'Yes', '1'. False: 'False', 'F', 'No', '0'. Boolean words are always case-insensistive (True=true).  
:T: <code></code> &rarr;  
:T: <code></code> &rarr;  
:F: <code></code>(default) &rarr;  

### Word lists
The word list is comma-separated. Prefixed and suffixed spaces are discarded (trimmed).  
:  
:Inner spaces are kept, and are part of the 'word':  
:  
:Any character apart from comma can be part of the word:  
:  

:Multiple spaces (whitespace) inside a string is reduced to a single space:  
:  

:equals  

;Spaces , Comma , quote , pipe  

;Trimmed spaces: All words are trimmed before checking (leading and trailing whitespace is removed; repeated inner whitespaces are reduced to one space):  
:T: <code></code> &rarr;  
:::...but the remaining in-word space does matter:  
:F: <code></code> &rarr;  

;Comma : When a comma is part of the word to check. Word strings that contain a comma can be made literal (escape the comma):  
:T: <code></code> &rarr;  
:??chk: <code></code> &rarr;  
:??chk: <code></code> &rarr;  

;Quote character : Conversely, quote characters that are part of the word are escaped by setting :  
:T: <code></code> &rarr;  

;Pipe : The pipe character can be entered as <code></code>  
:T: <code></code> &rarr;  

### Checking multiple words
It is possible to check *multiple words* against the source wordlist.  
;AND-words to check  
:: can have a *wordlist* (comma-separated as is). Each word will be checked against the source. When all and-words are found, the return value is True.  
:T: <code></code> &rarr;  
:T: <code></code> &rarr;  
:F: <code></code> &rarr;  

;OR-words to check  
:: can have a *wordlist* (comma-separated as 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: <code></code> &rarr;  
:T: <code></code> &rarr;  
:F: <code></code> &rarr;  

;Both AND-words, OR-words to check  
:, : can be used together. Each wordlist will get its own logical checks (AND-words must all be present; OR-words at least one)  
:T: <code></code> &rarr;  
:F: <code></code> &rarr;  

## todo
:**word order** in return string  

:**resove synonyms** eg  

;**Note 1.** The True return value is a list of *all* words found:  
:T: <code></code> &rarr;  
::return-text: add space after comma .  

;later  
;**Note 2.** Parameter is equal to  
:  
:T: <code></code> &rarr;  

; wordlist with OR-check  
: The wordlist requires that *at least one word of the list* is found.  
:T: <code></code> &rarr;  
::Here too, all found words are returned in the True-value  
:T: <code></code> &rarr;  

;Checking AND-wordlists, OR-wordlists:  
: and can be used together.  
:Words in the AND-list must all be present, the OR-list requires one or more words to be found.  
:When True, all hitwords are returned (once).  
:T: <code></code> &rarr;  

;option "count hits"  
:(unique, no aka's)  

;handle blanks  
:in {str find word|source={format|}|orwords=default, monotype, foo, &lt;blank>} - detect & separate blank  

;option notwords  
: -- reversed logic? what to output?  

;multiple AND-lists  
:"AND-1=(workday, 0700) OR AND-2=(weekend, 0900)"  
: basically works by adding twice: {IF:{sfw|andw|workday, 0700}{sfw|andw=weekend, 0900}|THEN...|ELSE}  
27 February 2023 (UTC)  

## Examples
| result | note |
| --- | --- |
| The comma is the word-delimiter |  |
| Spaces are trimmed, multi-space into one space |  |
| An inner space is a character too |  |
| Not case-sensistive by default |  |
| : case-sensistive | } |

## note
:The editor does not have to apply Lua patterns like  
:The editor does not have to interpret the return value (as in: "when ='blue' then ..."). They can prescribe the value even (yes-value, no-value).  

## Usage
### Basic
Core function:  
<pre>  

</pre>  

:When the *word* is found in the *source* (True), the function returns the *word* itself (by default), or value (when entered non-empty).  
:When not found (False), the function returns an empty string , or the value when entered.  

| result | note |
| --- | --- |
| "-" (hyphen) is part of the word |  |
| "_" (underscore) is part of the word |  |
| 'foo' is not the complete word |  |
| no entered |  |
| full word *foo-bar* not in the source |  |
| word *foo* not in the source as full word |  |
| } |  |

### All parameters
:All parameters, in three options  
| <pre>

</pre> | <pre>

</pre> | } |
| --- | --- | --- |
<pre></pre>  

### More options
| result | note |
| --- | --- |
| 'foo' is not the complete word |  |
| : a=A *(default)* |  |
| : a=/=A | } |

### word list
:Instead of a single word to check, a **list of target words** can be entered: . This -list will be treated with *AND*-logic: each and all of the words *must* be present. See:  

### AND-, OR-wordlist checks
: as noted, can be a *list of words*. all will be checked with the *AND*-requirement (each word must be present).  
: accepts a *list of words* that all will be checked with the *AND*-requirement (each word must be present).  
::When both , are present, they are combined into one single *AND*-wordlist.  
: 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.

- Pages with Unknown parameters are listed in .

: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).  

- : when in , display a report on input, output and the logical steps (debug).
- : When set in ns or on subpage , the Preview report is static (shown permanently).

<includeonly></includeonly>