Module:ProfitExtractor: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
(Created page with "-- Profit extraction module local p = {} function p.extractProfit(frame) -- Define the page from which to extract the profit local page = frame.args[1] -- The page name passed as an argument local profitText = mw.page.getContent(page) -- Get the full content of the page -- Pattern to match the profit number (assuming it's listed with the word "Profit") local profit = string.match(profitText, "Profit%s*:?%s*(%d[%d,]*)") -- Match a number like 350,...")
(No difference)

Revision as of 10:09, 5 May 2025

Documentation for this module may be created at Module:ProfitExtractor/doc

-- Profit extraction module
local p = {}

function p.extractProfit(frame)
    -- Define the page from which to extract the profit
    local page = frame.args[1]  -- The page name passed as an argument
    local profitText = mw.page.getContent(page)  -- Get the full content of the page

    -- Pattern to match the profit number (assuming it's listed with the word "Profit")
    local profit = string.match(profitText, "Profit%s*:?%s*(%d[%d,]*)")  -- Match a number like 350,168

    -- Return the profit value or a fallback message if not found
    return profit or "Profit not found"
end

return p