יחידה:מירכאות

מתוך חב"דפדיה, אנציקלופדיה חב"דית חופשית
גרסה מ־16:52, 4 ביולי 2024 מאת חלוקת קונטרסים (שיחה | תרומות) (מויקיפדיה:https://he.wikipedia.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%9E%D7%99%D7%A8%D7%9B%D7%90%D7%95%D7%AA)
(הבדל) → הגרסה הקודמת | הגרסה האחרונה (הבדל) | הגרסה הבאה ← (הבדל)
קפיצה לניווט קפיצה לחיפוש

ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:מירכאות/תיעוד

local p = {}

function p.removeQuotes_internal(str)
    local len = #str
    -- Check if the string starts and ends with a single quotation mark
    if len >= 2 and str:sub(1, 1) == "'" and str:sub(-1) == "'" then
        -- Check if there are two/three/five consecutive single quotation marks
        if (str:sub(2, 2) == "'" and str:sub(3, 3) ~= "'" and len >= 3) or
           (str:sub(2, 2) == "'" and str:sub(3, 3) == "'" and str:sub(4, 4) ~= "'" and len >= 4) or
           (str:sub(2, 2) == "'" and str:sub(3, 3) == "'" and str:sub(4, 4) == "'" and str:sub(5, 5) ~= "'" and len >= 5) then
            -- Return the original string without changes
            return str
        else
            -- Remove the first and last character (single quotation marks) from the string
            return str:sub(2, -2)
        end
    else
        -- No quotation marks, return the original string
        return str
    end
end

function p.removeQuotes( frame )
     str = frame.args.string
     return p.removeQuotes_internal(str)
end

return p