Name Extraction


#1

Hi Friends

i have following string

removed_email_address@domain.invalid~Vs~removed_email_address@domain.invalid

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


#2

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


#3

On Tue, Jan 27, 2009 at 12:05 PM, Newb N. removed_email_address@domain.invalid
wrote:

i have following string

removed_email_address@domain.invalid~Vs~removed_email_address@domain.invalid

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 =
“removed_email_address@domain.invalid~Vs~removed_email_address@domain.invalid”
=> “removed_email_address@domain.invalid~Vs~removed_email_address@domain.invalid”
irb(main):006:0> a.split(/[@~]/)
=> [“jayabharathy”, “angleritech.com”, “Vs”, “kannan”,
angleritech.com”]

Hope this helps,

Jesus.


#4

2009/1/27 Newb N. removed_email_address@domain.invalid:

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