hello frnds I want to store a split string in an array and then display it one by one. Eg:- Say suppose my db value is "My email id is abc-GXcTff7tL0M@public.gmane.org" then i want that only the email should be displayed so how will I do it pls reply thanks Dhaval Parikh -- 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 -~----------~----~----~----~------~----~------~--~---
Hi, Dhaval Parikh wrote:> I want to store a split string in an array and then display it one by > one.>> "my string".split=> ["my", "string"]> Eg:- Say suppose my db value is "My email id is abc-GXcTff7tL0M@public.gmane.org" then i want > that only the email should be displayed so how will I do it pls replyYou can use a regual expression for this.>> "My email id is abc-GXcTff7tL0M@public.gmane.org".match(/\S+@\S+\.\S+/)[0]=> "abc-GXcTff7tL0M@public.gmane.org" Of course this regular expression needs improvement because not all characters are valid. Lutz -- 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 -~----------~----~----~----~------~----~------~--~---
thanx a lot Lutz for your quick reply. -- 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 -~----------~----~----~----~------~----~------~--~---