Hi All
I'm trying to filter email adresses like this
#! /usr/bin/ruby
email = "test_test.test"
if email.scan(/\@/)
p "yes"
end
For some reason my program always prints 'yes'
How would should I do this ?
thnx
LuCa
···
--
Posted via http://www.ruby-forum.com/.
thnx, makes sense
How do you, BTW, exlude matches ?
!str.scan(pattern) do
...
end
doesn't work. Also a regex like
/[^pattern]/
doesn't work
···
--
Posted via http://www.ruby-forum.com/.
Hi --
thnx, makes sense
How do you, BTW, exlude matches ?
!str.scan(pattern) do
...
end
doesn't work. Also a regex like
/[^pattern]/
doesn't work
str =~ /@/
It's absolutely not a robust way to check for an email address, but it
will check for an at-sign
As for /[^pattern]/, that will match one character that is not a, e,
n, p, t, or r. For non-matching, try:
str !~ /pattern/
or maybe negative assertions in the regex.
David
···
On Sun, 20 Jul 2008, Luca Scaljery wrote:
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails July 21-24 Edison, NJ
Advancing With Rails August 18-21 Edison, NJ
See http://www.rubypal.com for details and updates!
David A. Black wrote:
Hi --
doesn't work
str =~ /@/
thnx, I was looking for a String#method but this is OK too
As for /[^pattern]/, that will match one character that is not a, e,
n, p, t, or r. For non-matching, try:
my mistake
thnx a lot
LuCa
···
On Sun, 20 Jul 2008, Luca Scaljery wrote:
--
Posted via http://www.ruby-forum.com/\.
you're right (I still have to get used to that!)
···
--
Posted via http://www.ruby-forum.com/.