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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Jan 2, 2007, at 2:22 PM, David Lelong wrote:> > 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 > > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You''ll probably want to get the data into an array and add each item
then. Try this:
emails = "omar-kMKSBuUQq7gi8rCdYzckzA@public.gmane.org,
aleena-f90FRFCoPy9ICGm3nVZjAw@public.gmane.org,
bleh-aPh8YMcqfxM@public.gmane.org,
feemqa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
email_arr = emails.split(", ")
email_arr.each do | email |
save_email_to_database(email) #Dummy method, replace with
something real
end
On Jan 2, 2007, at 2:22 PM, David Lelong wrote:>
> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---