hello frnds I want to match and fetch the string from the db contents so is there a method for it. The contents can be abc-GXcTff7tL0M@public.gmane.org or also <a href mailto:abc-GXcTff7tL0M@public.gmane.org</a> from both the things I want to fetch only the email id i.e abc-GXcTff7tL0M@public.gmane.org Can ne one help me out? 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,
data = "you data " (can be abc-pWbnnh6VMUY@public.gmane.org or <a
href=mailto:abc-pWbnnh6VMUY@public.gmane.org>
you do this
regex = /[:]?[a-zA-Z0-9]+@[a-zA-Z0-9]+.[a-zA-Z]{3}
if data =~ regex
puts "matched String:(email): #{$&}"
else
puts "no match"
end
$& contains the matched sting, $'' : contains the post string after
match, $`: contains the pre string that precedes your match criteria
P.s: change the regex value to what ever you want as necessary.
On Aug 21, 6:17 pm, Dhaval Parikh
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> hello frnds
>
> I want to match and fetch the string from the db contents so is there a
> method for it.
>
> The contents can be a...-GXcTff7tL0M@public.gmane.org or also <a href
mailto:a...-GXcTff7tL0M@public.gmane.org</a>
> from both the things I want to fetch only the email id i.e
a...-GXcTff7tL0M@public.gmane.org
>
> Can ne one help me out?
>
> Thanks
>
> Dhaval Parikh
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---
ok thanks but what if I want to use the samething with for loop then will it work? thanks a lot 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 -~----------~----~----~----~------~----~------~--~---
sure it will work, the value of data variable is going to be what ever
you want
example
array_of_objects = ["mailto:a@a.com", "a@a.com", ....]
array_of_objects.delete_if { |data|
!(data =~ regex)
}
On Aug 22, 4:37 pm, Dhaval Parikh
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> ok thanks but what if I want to use the samething with for loop then
> will it work?
>
> thanks a lot
>
> Dhaval Parikh
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---
I am currently using .match(/\S+@\S+\.\S+/) but i want to refine it...for the last string i.e after . i want to restrict the no of char to max 3 only the others should not be displayed ..can ne one tell me how to do it. 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 -~----------~----~----~----~------~----~------~--~---
.match(/\S+@\S+\.[a-zA-Z0-9]{3,3}/) (min number of char = 3 and max
number of char = 3)
.match(/\S+@\S+\.[a-zA-Z0-9]{3}/) (min number of char = 3 and max
number of char = unlimited)
.match(/\S+@\S+\.[a-zA-Z0-9]{,3}/) (min number of char = 0 and max
number of char = 3)
On Sep 6, 3:31 pm, Dhaval Parikh
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I am currently using .match(/\S+@\S+\.\S+/) but i want to refine
> it...for the last string i.e after . i want to restrict the no of char
> to max 3 only the others should not be displayed ..can ne one tell me
> how to do it.
>
> thanks
>
> dhaval parikh
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---
hannes.tyden-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-07 07:41 UTC
Re: fetch string matching with email
I you were not already, I want to make you aware that there are top level domains with names longer than three characters. "museum" for instance. Wikipedia has the whole list: http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains On Sep 7, 6:37 am, raghukumar <raghukumar.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> .match(/\S+@\S+\.[a-zA-Z0-9]{3,3}/) (min number of char = 3 and max > number of char = 3) > .match(/\S+@\S+\.[a-zA-Z0-9]{3}/) (min number of char = 3 and max > number of char = unlimited) > .match(/\S+@\S+\.[a-zA-Z0-9]{,3}/) (min number of char = 0 and max > number of char = 3) > > On Sep 6, 3:31 pm, Dhaval Parikh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > I am currently using .match(/\S+@\S+\.\S+/) but i want to refine > > it...for the last string i.e after . i want to restrict the no of char > > to max 3 only the others should not be displayed ..can ne one tell me > > how to do it. > > > thanks > > > dhaval parikh > > -- > > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
thanks a lot to both of you i modified the code a bit as per your suggestions -- 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 -~----------~----~----~----~------~----~------~--~---