Copy link to clipboard
Copied
Hi I want to split string(7<>2,,3<>6<>0.6) by specific character(<>) and store it in array...like c# code :
string[] wordsStrings = Regex.Split(dataList, "<>");
You want to use ColdFusion's ListToArray function. Treat the <> as a list delimiter. The important part here is setting the last argument to true, for the multiCharacterDelimiter argument.
dataList = "7<>2,,3<>6<>0.6";
wordsStrings = listToArray(dataList, "<>", false, true);
Copy link to clipboard
Copied
You want to use ColdFusion's ListToArray function. Treat the <> as a list delimiter. The important part here is setting the last argument to true, for the multiCharacterDelimiter argument.
dataList = "7<>2,,3<>6<>0.6";
wordsStrings = listToArray(dataList, "<>", false, true);
Copy link to clipboard
Copied
Shraddha Prajapati wrote:
string[] wordsStrings = Regex.Split(dataList, "<>");
That is a bit confusing. Do you mean this:
String[] wordsStrings = dataList.split("<>")
or, its equivalent,
regex = "<>";
String[] wordsStrings = dataList.split(regex);
If so, you already have one solution, Duncancumming's. Another is:
<cfscript>
dataList = createobject("java","java.lang.String").init("7<>2,,3<>6<>0.6");
wordsStrings = dataList.split("<>");
</cfscript>
<cfdump var="#wordsStrings#">
Copy link to clipboard
Copied
<cfscript>
dataList = createobject("java","java.lang.String").init("7<>2,,3<>6<>0.6");
wordsStrings = dataList.split("<>");
</cfscript>
<cfdump var="#wordsStrings#">
Its also correct answer....