Bản mẫu:Findpagetext/doc
Đây là một trang con tài liệu sử dụng bản mẫu dành cho Bản mẫu:Findpagetext. Nó gồm có các thông tin hướng dẫn sử dụng, thể loại và các nội dung khác không thuộc về phần trang bản mẫu gốc. |
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}}
→ 761{{findpagetext |text=Youghiogheny}}
→ 761{{findpagetext |text=Youghiogheny |nomatch=0}}
→ 761{{findpagetext |text=Youghiogheny |title=Boston Bridge |nomatch=not found}}
→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{findpagetext |text=river |title=Boston Bridge}}
→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{findpagetext |text=river |title=Boston Bridge |nomatch=not found}}
→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{findpagetext |text=[Rr]iver |title=Boston Bridge |plain=false |nomatch=not found}}
→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{findpagetext |text=%[%[ |title=Boston Bridge |plain=f}}
→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{findpagetext |text=%{%{[Cc]oord |title=Boston Bridge |plain=f}}
→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).
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.