<cfscript>
myList = '2003/09/09 14:49:05, "TestUser1", "/Doc/News/Budgeting,Forecasting & Reporting.doc", "OK"';
myList = REReplace(myList, '^[[:space:]]*([^,]*|"([^"]|"")*")[[:space:]]*(,|$)','');
</cfscript>
<cfoutput>#myList#</cfoutput>
>This should do it in CF using regexp.
>There are probably custom tags that will read logs more efficiently
>though.
>
><cfscript>
>columns = "DateTime,User,Document,Status";
>qTmp = QueryNew(columns);
>pattern = '^[[:space:]]*([^,]*|"([^"]|"")*")[[:space:]]*(,|$)';
>matchStruct = structNew();
>for(i=2;i LE ListLen(fOutput,chr(10));i=i+1){
>QueryAddRow(qTmp,1);
>line = ListGetAt(fOutput,i,chr(10));
>exit = false;
>j = 1;
>while(NOT exit){
>// find matching pattern
>matchStruct = REFindNoCase(pattern,line,1,true);
>if(matchStruct.pos[1] AND j LE ListLen(columns)){
>field = Mid(line,matchStruct.pos[2],matchStruct.len[2]);
>QuerySetCell(qTmp,ListGetAt(columns,j),field);
>if(matchStruct.len[1])
>line = RemoveChars(line,1,matchStruct.len[1]);
>j = j + 1;
>}
>else exit = true;
>}
>}
></cfscript>
>
>
> -----Oorspronkelijk bericht-----
> Van: ColdFusion Programmer [mailto:[EMAIL PROTECTED]
> Verzonden: wo 8/10/2003 15:53
> Aan: CF-Talk
> CC:
> Onderwerp: Re:Looping through a list, setting each listItem to a
>column
>
>
> Have tried but can't crack it. Can you please show me how to do it if
>you don't mind, thanks in advance.
>
> >Yes a regular _expression_ (regex) , what you would want is a regex
>that
> >finds any commas that are between quotation marks and either
>escapes
> >them or replaces them.
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

