CFLib.org – Common Function Library Project

string2List(s[, delim])

Last updated May 26, 2005

author

Joshua Miller

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Converts a string to a list using the specified delimter (defaults to comma). Returns a list.

Return Values:
Returns a string.

Example:

<cfoutput>
#string2List("ABCDEFGHIJKLMNOPQRSTUVWXYZ")#
</cfoutput>

Parameters:

Name Description Required
s String to modify. Yes
delim Delimiter to use for new list. Defaults to a comma. No

Full UDF Source:

/**
 * Converts a string to a list using the specified delimter (defaults to comma). Returns a list.
 * 
 * @param s      String to modify. (Required)
 * @param delim      Delimiter to use for new list. Defaults to a comma. (Optional)
 * @return Returns a string. 
 * @author Joshua Miller (josh@joshuasmiller.com) 
 * @version 1, May 26, 2005 
 */
function string2List(s){
    var i=0;
    var l="";
    var delim=",";
    
    if(arrayLen(arguments) gt 2) delim = arguments[3];
    
    for(i=1;i lte Len(s);i=i+1) l = listAppend(l,mid(s,i,1),delim);

    return l;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson