Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a2345fbd2f644a3e

Jump to content

Module:Regex

From Wikipedia, the free encyclopedia
local p = {}
local getArgs = require('Module:Arguments').getArgs

--args: 1 - page to search, 2 - match pattern

local function allcases(s)
	return s:gsub('([%?%^%$%(%)%%%.%[%]%*%+%-])', '%%%1')
		:gsub('%a', function(letter) return '['..letter:upper()..letter:lower()..']' end)
		:gsub('%[([^%[%]]+)%]', '%1')
end

function p._match(args)
	local page = mw.title.new(args["1"])
	if not page then
		--bad title
		return ""
	end
	local redirectTarget = page.redirectTarget
	if redirectTarget then page = mw.title.new(redirectTarget.prefixedText) end
	local content = page:getContent()
	if not content then
		--page does not exist
		return ""
	end
	local pattern = args["2"] or ""
	return mw.ustring.match(content, pattern)
end

function p.match(frame)
	local args = getArgs(frame)
	return p._match(args)
end

return p