Module:CefiAlphabet

--[[          /$$                                                /$$                                                     | $$                                               | $$                                             /$$$$$$$| $$$$$$$   /$$$$$$   /$$$$$$  /$$$$$$   /$$$$$$$ /$$$$$$    /$$$$$$   /$$$$$$                     /$$_____/| $$__  $$ |____  $$ /$$__  $$|____  $$ /$$_____/|_  $$_/   /$$__  $$ /$$__  $$                    \_______/|__/  |__/ \_______/|__/      \_______/ \_______/   \___/   \_______/|__/                                                        /$$                                                                   /$$                                  | $$                                                                  | $$      /$$$$$$   /$$$$$$   /$$$$$$ | $$  /$$$$$$   /$$$$$$$  /$$$$$$  /$$$$$$/$$$$   /$$$$$$  /$$$$$$$  /$$$$$$   /$$__  $$ /$$__  $$ /$$__  $$| $$ |____  $$ /$$_____/ /$$__  $$| $$_  $$_  $$ /$$__  $$| $$__  $$|_  $$_/                      | $$                                                                                                        | $$                                                                                                        |__/                                                                                     /$$                 /$$                                                                                     /$$ /$$$$$$$       | $$ /$$   /$$  /$$$$$$
 * $$     | $$  \ $$  /$$$$$$$| $$  \__/ /$$$$$$$| $$        | $$    | $$$$$$$$| $$  \__/
 * $$     | $$  | $$ /$$__  $$| $$      /$$__  $$| $$        | $$ /$$| $$_____/| $$
 * $$ \__/| $$$$$$$$| $$  \ $$| $$  /$$$$$$$| $$      | $$$$$$$$| $$ \ $$ \ $$| $$$$$$$$| $$  \ $$  | $$
 * $$     | $$_____/| $$  | $$| $$ /$$__  $$| $$      | $$_____/| $$ | $$ | $$| $$_____/| $$  | $$  | $$ /$$
 * __/      \_______/| $$____/ |__/ \_______/ \_______/ \_______/|__/ |__/ |__/ \_______/|__/  |__/   \___/
 * __/      \_______/| $$____/ |__/ \_______/ \_______/ \_______/|__/ |__/ |__/ \_______/|__/  |__/   \___/
 * __/               | $$
 * $$| $$__ $$      | $$| $$  | $$ |____  $$
 * $$| $$ | $$      | $$| $$  | $$ /$$__  $$
 * __/|__/ |__/      |__/ \______/  \_______/
 * __/|__/ |__/      |__/ \______/  \_______/
 * __/|__/ |__/      |__/ \______/  \_______/

Code licenced under the Giant Penis License (GPL). Copyright (c) 2019 Emiel Sebastiaan Hardy --]] local str = {}

function str.replace( frame ) local new_args = str._getParameters( frame.args, {'source', 'charcount', 'chararray', 'charreparray', 'nochar', 'bruh' } ); local source_str = new_args['source'] or ''; local charcount = tonumber( new_args['charcount'] ); local chararray = new_args['chararray'] or ''; local charreparray = new_args['charreparray'] or ''; local nochar = new_args['nochar'] or ''; local bruh = new_args['bruh'] or ''; local charcountuwu; local foobar = {}; local owouwu = {}; if bruh ~= '' then error("Bruh moment"); end if source_str == '' then error("Add source string"); end if chararray == '' then error("Add characters that need to be replaced"); end if charreparray == '' then error("Add characters to replace them with"); end if #chararray ~= #charreparray then error("Same amount of characters needed"); end if nochar ~= '' then error("Bruh moment: will add soon"); else for i = 1, #chararray do           foobar[i] = mw.ustring.sub(chararray, i, i)        end for i = 1, #charreparray do           owouwu[i] = mw.ustring.sub(charreparray, i, i)        end for charcountuwu = 1, charcount do           source_str = mw.ustring.gsub( source_str, foobar[charcountuwu], owouwu[charcountuwu] ); end end return source_str; end

-- Helper function that populates the argument list given that user may need to use a mix of named and unnamed parameters. This is relevant because named parameters are not identical to unnamed parameters due to string trimming, and when dealing with strings we sometimes want to either preserve or remove that whitespace depending on the application. function str._getParameters( frame_args, arg_list ) local new_args = {}; local index = 1; local value; for i,arg in ipairs( arg_list ) do       value = frame_args[arg] if value == nil then value = frame_args[index]; index = index + 1; end new_args[arg] = value; end return new_args; end

function str.len( frame ) local new_args = str._getParameters( frame.args, {'s'} ); local s = new_args['s'] or ''; return mw.ustring.len( s ) end

-- Helper Function to interpret boolean strings function str._getBoolean( boolean_str ) local boolean_value; if type( boolean_str ) == 'string' then boolean_str = boolean_str:lower; if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0' or boolean_str == '' then boolean_value = false; else boolean_value = true; end elseif type( boolean_str ) == 'boolean' then boolean_value = boolean_str; else error( 'No boolean value found' ); end return boolean_value end

-- Helper function that escapes all pattern characters so that they will be treated as plain text. function str._escapePattern( pattern_str ) return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ); end

return str