Removing unwanted comma's

Nicolas Cueto niconiko at
Sat Apr 5 19:16:48 EDT 2008

> Example:
> fieldonedata,fieldtwodata,"fieldthree,data", fieldfourdata,etc.
> I need to remove the quotes the comma located within the quotes as
> well as the quote characters, to end up with this:
> fieldonedata,fieldtwodata,fieldthreedata, fieldfourdata,etc.

Here's one way:

put yourOldData into tDataString
repeat until quote is not among the chars of tDataString
 put offset(quote,tDataString) into tLeftQuotePoz
 put tLeftQuotePoz into tStringPoz
 put empty into tNewString
  add 1 to tStringPoz
  switch (char tStringPoz of tDataString)
  case comma
   next repeat
  case quote
   put tStringPoz into tRightQuotePoz
   exit repeat
   put char tStringPoz of tDataString after tNewString
  case (tStringPoz > the number of chars in tDataString)
   exit repeat -- Just to be safe, a default way of exiting this
repeat loop.
  end switch
 end repeat
 put char tLeftQuotePoz to tRightQuotePoz of tDataString into
 delete char tLeftQuotePoz to tRightQuotePoz  of tDataString
 put tNewString after char (tLeftQuotePoz - 1) of tDataString
end repeat
put tDataString into yourNewData


Nicolas Cueto

More information about the Use-livecode mailing list