Difference between revisions of "Template:Find page text/doc"
Jump to navigation
Jump to search
imported>WOSlinker (add cat) |
imported>WOSlinker (lua) |
||
| Line 1: | Line 1: | ||
{{Documentation subpage}} | {{Documentation subpage}} | ||
| + | {{lua|Module:String2}} | ||
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> | <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> | ||
Wrapper for findpagetext function in [[Module:String2]]. | Wrapper for findpagetext function in [[Module:String2]]. | ||
Revision as of 18:00, 14 December 2020
| This is a documentation subpage for Template:Find page text. It contains usage information, categories and other content that is not part of the original template page. |
| This template uses Lua: |
Wrapper for findpagetext function in Module:String2.
The Findpagetext template returns the position of a piece of text in the wikitext source of a page. It takes up to four parameters:
- First positional parameter or |text is the text to be searched for.
- Optional parameter |title is the page title, defaults to the current page.
- Optional parameter |plain is either true for a plain search (default), or false for a Lua pattern search.
- Optional parameter |nomatch is the value returned when no match is found; default is nothing.
- Examples
{{findpagetext |Youghiogheny}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=Youghiogheny}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=Youghiogheny |nomatch=0}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=Youghiogheny |title=Boston Bridge |nomatch=not found}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=river |title=Boston Bridge}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=river |title=Boston Bridge |nomatch=not found}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=[Rr]iver |title=Boston Bridge |plain=false |nomatch=not found}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=%[%[ |title=Boston Bridge |plain=f}}→ Script error: The function "findpagetext" does not exist.{{findpagetext |text=%{%{[Cc]oord |title=Boston Bridge |plain=f}}→ Script error: The function "findpagetext" does not exist.
The search is case-sensitive, so Lua pattern matching is needed to find river or River. The last example finds {{coord or {{Coord. The penultimate example finds a wiki-link.