Bản mẫu:Find page text
Giao diện
| Bản mẫu này được sử dụng ở rất nhiều trang, vì thế những thay đổi đến nó sẽ hiện ra rõ ràng. Vui lòng thử nghiệm các thay đổi ở trang con /sandbox, /testcases của bản mẫu, hoặc ở không gian người dùng của bạn. Cân nhắc thảo luận các thay đổi tại trang thảo luận trước khi áp dụng sửa đổi. |
| Bản mẫu này sử dụng Lua: |
Wrapper for findpagetext function in Module:String2.
Template:Find page text returns the position of a piece of text in the wikitext source of a page.
Parameters
[sửa mã nguồn]The template takes up to four parameters:
|1=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
[sửa mã nguồn]{{Find page text|Youghiogheny}}→{{Find page text|text=Youghiogheny}}→{{Find page text|text=Youghiogheny|nomatch=0}}→ 0{{Find page text|text=Youghiogheny|title=Boston Bridge|nomatch=not found}}→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{Find page text|text=river|title=Boston Bridge}}→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{Find page text|text=river|title=Boston Bridge|nomatch=not found}}→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{Find page text|text=[Rr]iver|title=Boston Bridge|plain=false|nomatch=not found}}→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{Find page text|text=%[%[|title=Boston Bridge|plain=f}}→ Lỗi Lua: bad argument #1 to 'find' (string expected, got nil).{{Find page text|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.
See also
[sửa mã nguồn]- {{if in page}}