The String Helper file contains handlers that assist in working with strings.
Loading this Helper
This helper is loaded using the following code:
The following handlers are available:
Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.
The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:
- alnum: Alpha-numeric string with lower and uppercase characters.
- numeric: Numeric string.
- nozero: Numeric string with no zeros.
- unique: A md5 encrypted UUID. Note: The length parameter is not available for this type. Returns a fixed length 32 character string.
put rigRandomString("alnum", 16) into tRandomString
Allows two or more items to be alternated between, when cycling through a loop. Example:
rigResetAlternator repeat with i = 1 to 10 put rigAlternator("string one", "string two") after tAlternated end repeat
Note: To use multiple separate calls to this function call the rigResetAlternator handler first.
You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.
rigResetAlternator repeat with i = 1 to 10 put rigAlternator("one", "two", "three", "four", "five") after tAlternated end repeat
Generates repeating copies of the data you submit. Example:
put return into tString put rigRepeater(tString, 30) into tRepeaatedString
The above would generate 30 newlines.
Converts double slashes in a string to a single slash, except those found in http://. Example:
put "http://example.com//index.lc" into tString put rigReduceDoubleSlashes(tString) into tString -- results in "http://example.com/index.lc"
Removes any leading/trailing slashes from a string. Example:
put "/this/that/theother/" into tString put rigTrimSlashes(tString) into tString -- results in this/that/theother
Reduces multiple instances of a particular character occuring directly after each other. Example:
put "Fred, Bill,, Joe, Jimmy" into tString put rigReduceMultiples(tString,",") into tString -- results in "Fred, Bill, Joe, Jimmy"
The function accepts the following parameters:
The first parameter contains the string in which you want to reduce the multiples. The second parameter contains the character you want to have reduced. The third parameter is FALSE by default; if set to TRUE it will remove occurences of the character at the beginning and the end of the string. Example:
rigReduceMultiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)
put ",Fred, Bill,, Joe, Jimmy," into tString put rigReduceMultiples(tString, ",", TRUE) into tString -- results in "Fred, Bill, Joe, Jimmy"
Converts single and double quotes in a string to the corresponding HTML entities. Example:
put "Joe's" && quote & "dinner" & quote into tString put rigQuotesToEntities(tString) into tString -- results in "Joe's "dinner""
Removes single and double quotes from a string. Example:
put "Joe's" && quote & "dinner" & quote into tString put rigStripQuotes(tString) into tString -- results in "Joes dinner"