Remove Commas from String

Hi,

I have a comma-delimited list of email addresses like:

email1, email2, email3…

that I am adding into individual rows in a database.

How do I remove the commas prior to inserting the data into the
database?

Thanks,

David

is this a string separated with commas, or an array?

if it’s a string: the_string.gsub(/,/,"")

…should do it (not tested, sorry).

-Jason

You’ll probably want to get the data into an array and add each item
then. Try this:

emails = “[email protected], [email protected],
[email protected], [email protected]

email_arr = emails.split(", ")

email_arr.each do | email |
save_email_to_database(email) #Dummy method, replace with
something real
end