Removing unwanted comma's

Mark Schonewille m.schonewille at economy-x-talk.com
Sat Apr 5 18:49:21 EDT 2008


Hi David,

If you don't have spaces and tabs in your data, you can do this:

function removeCommas theData
   replace comma with space in theData
   replace cr with numToChar(14) in theData
   repeat for every word myWord in theData
     if myWord contains space then replace space with empty in myWord
     replace quote with empty in myWord
     put myWord & comma after myNewData
   end repeat
   replace numToChar(14) with cr in myNewData
   return myNewData
end removeCommas

A not so quick and yet dirty solution. Important: this solution won't  
work if there are opening quotes without a closing quote. Maybe  
someone can come up with a nice regex solution, I wonder.

Best regards,

Mark Schonewille

--

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

A large collection of scripts for HyperCard, Revolution, SuperCard and  
other programming languages can be found at http://runrev.info




On 6 apr 2008, at 00:12, David Coker wrote:
> Hello folks,
> I ran into a problem that I just can't seem to figure out and hope
> someone can offer a suggestion or solution. (More than likely simple
> using Rev, but it surely escapes me.) Is there a way to remove
> spurious comma's inside a text field that contains comma delimited
> data, while maintaining the integrity of the individual data fields?
>
> 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.
>
> I've wasted a big portion of my day trying to figure this out and
> would really appreciate any help I can get.
>
> David





More information about the use-livecode mailing list