Hi Friends
i have following string
[email protected][email protected]
the above string has 2 email ids in it.but i need only names of it.
i want to extract only the names
jayabharathy
kannan
how can i implemend that
Kindly Let me Know
Hi Friends
i have following string
[email protected][email protected]
the above string has 2 email ids in it.but i need only names of it.
i want to extract only the names
jayabharathy
kannan
how can i implemend that
Kindly Let me Know
Newb N. escreveu:
jayabharathy
kannan
how can i implemend that
Kindly Let me Know
Hi !
I think you can do this with regular expressions.
look some at :
http://www.regular-expressions.info/ruby.html
http://www.rubyist.net/~slagell/ruby/regexp.html
Regards,
-tiago
On Tue, Jan 27, 2009 at 12:05 PM, Newb N. [email protected]
wrote:
i have following string
[email protected][email protected]
the above string has 2 email ids in it.but i need only names of it.
i want to extract only the names
Take a look at the split method in String:
http://www.ruby-doc.org/core/classes/String.html#M000818
For example:
irb(main):001:0> a =
“[email protected][email protected]”
=> “[email protected][email protected]”
irb(main):006:0> a.split(/[@~]/)
=> [“jayabharathy”, “angleritech.com”, “Vs”, “kannan”,
“angleritech.com”]
Hope this helps,
Jesus.
2009/1/27 Newb N. [email protected]:
jayabharathy
kannan
Something like this can work, depends of course on the names that you
want to allow:
names = str.scan(/(\w+)@[a-z._-]+/i).flatten
Cheers
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs