Module:String2: Difference between revisions

Content deleted Content added
add p.isnumeric, which is a more WP:PEIS-efficient implementation of Template:Isnumeric
adding getError() when an error text is needed from a longer text
Line 12:
end
 
p.ucfirst = function (frame )
local s = frame.args[1];
if not s or '' == s or s:match ('^%s+$') then -- when <s> is nil, empty, or only whitespace
Line 87:
 
 
p.title = function (frame )
-- http://grammar.yourdictionary.com/capitalization/rules-for-capitalization-in-titles.html
-- recommended by The U.S. Government Printing Office Style Manual:
Line 389:
end
return boolean and 0 or ''
end
 
-- Returns an error found in a string.
function p.getError(frame)
local text = frame.args[1] or frame:getParent().args[1]
mw.log(text)
local error_message = text:match('(<strong class="error">.-</strong>)')
return error_message or nil
end