Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:If in page
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local getArgs = require('Module:Arguments').getArgs --args: 1 - ustring pattern, 2 - value if present, 3 - value if absent, -- page - page to test if not this page function p._main(args) if not args["page"] then args.page = mw.title.getCurrentTitle().fullText end local page = mw.title.new(args.page) if not page then --bad title return args["3"] or "" end local content = page:getContent() if not content then --page does not exist return args["3"] or "" end if mw.ustring.match(content, args["1"] or "") then if args["sub"] then --return value should have capture groups substed in local pattern = args["1"] or "" if mw.ustring.sub(pattern, 1, 1) ~= "^" then --pattern does not force it to be at start of page pattern = "^.-" .. pattern end if mw.ustring.sub(pattern, -1) ~= "$" then --pattern does not force it to be at end of page pattern = pattern .. ".*$" end --pattern will now match entire content, so running gsub will --return the string that has been passed in parameter 2 with things --like %1 substituted, NOTE: %0 does not work in this local out = mw.ustring.gsub(content, pattern, args["2"] or "") return out else return args["2"] or "" end else return args["3"] or "" end end function p.main(frame) local args = getArgs(frame) return p._main(args) end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Error
(
edit
)
Template:High-use
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Slink
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:If in page/doc
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)