raghukumar
(raghukumar)
August 21, 2007, 5:58pm
#1
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.
raghukumar
(raghukumar)
August 22, 2007, 3:04pm
#2
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)
}
raghukumar
(raghukumar)
September 7, 2007, 4:37am
#3
.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)
hannes.tyden
(hannes.tyden@gmail.com)
September 7, 2007, 7:41am
#4
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