fetch string matching with email

Hi Dhaval,

data = "you data " (can be abc@abc.om or <a href=mailto:abc@abc.om>

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.

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)
}

.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)

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