Template:Find

From Constant Noble
Jump to navigation Jump to search

Please select a valid function ("text"/"txtb", "first"/"fstb", or "last"/"lstb").

Template documentation

Documentation icon
Documentation icon
This is transcluded from Documentation:Find (edit).

{{Find}} is a module-based template which partly stands in for RegexFunctions, disabled on Miraheze per phab:T8866.

Code

{{Find|func|text|str}}

where func must be replaced by one of three function options, which will search for the given case-sensitive string (str):

  • in the supplied text (or with txtb);
  • at the start of a text (first or fstb); or
  • at the end thereof (last or lstb).

"txtb", "fstb", and "lstb" respectively stand for "text (boolean)", "first (boolean)", and "last (boolean)".

Depending on whether str matches, the value will be the starting position number (for text searches), "1" for successful first or last matches, or "0"/empty if unmatched.

Usage

Code Output Regex
{{Find|text|Find this word|this}} 6 /this/
{{Find|txtb|Find this word|this}} 6 /this/
{{Find|text|Find this word|that}} /that/
{{Find|txtb|Find this word|that}} 0 /that/
{{Find|first|In the beginning|In}} 1 /^In/
{{Find|fstb|In the beginning|In}} 1 /^In/
{{Find|first|In the beginning|Not}} /^Not/
{{Find|fstb|In the beginning|Not}} 0 /^Not/
{{Find|last|Alpha and Omega|a}} 1 /a$/
{{Find|lstb|Alpha and Omega|a}} 1 /a$/
{{Find|last|Alpha and Omega|o}} /o$/
{{Find|lstb|Alpha and Omega|o}} 0 /o$/
From Wikipedia
From Wikipedia

Part or all of this page uses material from Module:String, originally located at Wikipedia. The list of original contributors can be found in its page history. Text on Wikipedia is available under the Creative Commons Attribution-ShareAlike 3.0 license; additional terms may apply.