Removing unwanted comma's
Nicolas Cueto
niconiko at gmail.com
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
repeat
add 1 to tStringPoz
switch (char tStringPoz of tDataString)
case comma
next repeat
break
case quote
put tStringPoz into tRightQuotePoz
exit repeat
break
default
put char tStringPoz of tDataString after tNewString
break
case (tStringPoz > the number of chars in tDataString)
exit repeat -- Just to be safe, a default way of exiting this
repeat loop.
break
end switch
end repeat
put char tLeftQuotePoz to tRightQuotePoz of tDataString into
tTheString
delete char tLeftQuotePoz to tRightQuotePoz of tDataString
put tNewString after char (tLeftQuotePoz - 1) of tDataString
end repeat
put tDataString into yourNewData
Cheers,
Nicolas Cueto
More information about the use-livecode
mailing list