[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Name Extraction

Newb Newb

1/27/2009 11:05:00 AM

Hi Friends

i have following string

jayabharathy@angleritech.com~Vs~kannan@angleritech.com

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
--
Posted via http://www.ruby-....

3 Answers

Tiago Nogueira

1/27/2009 11:20:00 AM

0

Newb Newb escreveu:
> Hi Friends
>
> i have following string
>
> jayabharathy@angleritech.com~Vs~kannan@angleritech.com
>
> 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 !
I think you can do this with regular expressions.
look some at :
http://www.regular-expressions.info...
http://www.rubyist.net/~slagell/ruby/r...

Regards,
-tiago

Jesús Gabriel y Galán

1/27/2009 12:27:00 PM

0

On Tue, Jan 27, 2009 at 12:05 PM, Newb Newb <revathy.p@angleritech.com> wrote:

> i have following string
>
> jayabharathy@angleritech.com~Vs~kannan@angleritech.com
>
> 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.ht...

For example:

irb(main):001:0> a = "jayabharathy@angleritech.com~Vs~kannan@angleritech.com"
=> "jayabharathy@angleritech.com~Vs~kannan@angleritech.com"
irb(main):006:0> a.split(/[@~]/)
=> ["jayabharathy", "angleritech.com", "Vs", "kannan", "angleritech.com"]

Hope this helps,

Jesus.

Robert Klemme

1/27/2009 1:49:00 PM

0

2009/1/27 Newb Newb <revathy.p@angleritech.com>:
> Hi Friends
>
> i have following string
>
> jayabharathy@angleritech.com~Vs~kannan@angleritech.com
>
> 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

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

--
remember.guy do |as, often| as.you_can - without end