Jump to content
Gold Sponsor: Data-Way IT-Consulting, Austria

  • String Helper Functions

    String Helper Functions


    14 pages in this category

    1. AddLeadingZeros()

      Lua   SwxWare v13.10   This helper function takes a string or a number (converts it into a string) and adds leading zeros ("0") until a given length is reached.   local sNumber = AddLeadingZeros(szSource, nExpectedNumberLength)     This functions returns a string value.     Example:   local nNumber = 2 local sNumber = AddLeadingZeros(nNumber, 4) PBXScript.OutputTrace("sNumber = " .. sNumber) --> sNumber = 0002    
      • 46 views
    2. IsEmailString()

      Lua   SwxWare v13.10   This helper function checks, if the given string is an email address.   local bEmail = IsEmailString(str)     This function returns a boolean value.   The check for a valid email email address is quite simple, it will just be checked if there is an "@" character within the given string.      Example:   local bEMail = IsEmailString("test@test.com") PBXScript.OutputTrace ("bEMail = " ..tostring(bEMail)) --&
      • 25 views
    3. IsInString()

      Lua   SwxWare v13.10   This helper function checks is a given substring is part of a given string.   local bFound = IsInString(str, substr)     This function returns a boolean value.     Examples:   local bFound = IsInString("+494012345", "123") PBXScript.OutputTrace("bFound = " .. tostring(bFound)) --> bFound = true   local bFound = IsInString("Erika Mustermann", "Herbert") PBXScript.OutputTrace("bFound = " .. tostring(bFound)
      • 25 views
    4. IsString()

      Lua   SwxWare v13.10   This helper function checks if the given parameter is of type string.   local bString = IsString(str)     This function returns a boolean value.     Examples:   local bString = IsString("I am a string") PBXScript.OutputTrace("bString = " .. tostring(bString)) --> bString = true   local bString = IsString(12345) PBXScript.OutputTrace("bString = " .. tostring(bString)) --> bString = false    
      • 19 views
    5. StringLeft()

      Lua   SwxWare v13.10   This helper function returns the given number of characters from the left side of the given string.   local sLeft = StringLeft(str, len)     This function returns a string value.     Examples:   local sLeft = StringLeft("Erika Mustermann", 5) PBXScript.OutputTrace("sLeft = " .. sLeft) --> sLeft = Erika   local tConfig = nil local sPublicLineAccess = "" tConfig = PBXScript.GetPBXConfig() sPublicLineAccess
      • 22 views
    6. StringLen()

      Lua   SwxWare v13.10   This helper function returns the length of a given string.   local nLength = StringLen(str)     This function returns a number value.     Examples:   local nLength = StringLen("Erika Mustermann") PBXScript.OutputTrace("nLength = " .. tostring(nLength)) --> nLength = 16   local tConfig = nil local sPublicLineAccess = "" tConfig = PBXScript.GetPBXConfig() sPublicLineAccess = tConfig.publicaccessprefix PBXSc
      • 19 views
    7. StringLTrim()

      Lua   SwxWare v13.10   The helper function removes all space characters from the left from a given string.   local sLeft = StringLTrim(str)     This function returns a string value.     Example:   local sLeft = StringLTrim(" Erika Mustermann ") PBXScript.OutputTrace("#" .. sLeft .. "#") --> #Erika Mustermann #    
      • 20 views
    8. StringMid()

      Lua   SwxWare v13.10   This helper function returns a given number of characters from a given position from within a given string.   local sMid = StringMid(str, pos, len)     This function returns a string value.     Example:   local sMid = StringMid("Erika Mustermann", 7, 6) PBXScript.OutputTrace("sMid = " .. sMid) --> sMid = Muster    
      • 29 views
    9. StringPos()

      Lua   SwxWare v13.10   This helper function search the first occurance of a substring within a string an returns its position.   local nPos = StringPos(str, substr)     This function returns a number value.     Example:   local nPos = StringPos("Erika Mustermann", "Muster") PBXScript.OutputTrace("nPos = " .. tostring(nPos)) --> nPos = 7    
      • 26 views
    10. StringReplace()

      Lua   SwxWare v13.10   This helper function replaces a given substring within a given string by a replacement substring.   local sReplace = StringReplace(str, substr, repl)     This function returns a string value.     Example:   local sReplace = StringReplace("Erika Mustermann", "Muster", "Bau") PBXScript.OutputTrace("sReplace = " .. sReplace) --> sReplace = Erika Baumann    
      • 21 views
    11. StringRight()

      Lua   SwxWare v13.10   This helper function returns the given number of characters from the right side of the given string.   local sRight = StringRight(str, len)     This function returns a string value.     Example:   local sRight = StringRight("Erika Mustermann", 4) PBXScript.OutputTrace("sRight = " .. sRight) --> sRight = mann    
      • 20 views
    12. StringRTrim()

      Lua   SwxWare v13.10   The helper function removes all space characters from the right from a given string.   local sRight = StringRTrim(str)     This function returns a string value.     Example:   local sRight = StringRTrim(" Erika Mustermann ") PBXScript.OutputTrace("#" .. sRight .. "#") --> # Erika Mustermann#    
      • 21 views
    13. StringSplitToTable()

      Lua   SwxWare v13.10   This helper function splits parts of a given string, separated by a given separator, into a table.   local tParts = StringSplitToTable(sInput, sSeperator)     This function returns a table of string values.     Example:   local tParts = StringSplitToTable("111;222;333;444", ";") for i = 1, #tParts do PBXScript.OutputTrace("tParts[" .. tostring(i) .. "] = " .. tParts[i]) end --> tParts[1] = 111 --> tParts[
      • 23 views
    14. StringTrim()

      Lua   SwxWare v13.10   The helper function removes all space characters from the left and right from a given string.   local sTrim = StringTrim(str)     This function returns a string value.     Example:   local sTrim = StringTrim(" Erika Mustermann ") PBXScript.OutputTrace("#" .. sTrim .. "#") --> #Erika Mustermann#    
      • 18 views
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.