t; [mailto:rubyonrails-talk@googlegroups.com
> ] On Behalf Of David Liwoch
> Sent: Thursday, September 11, 2008 12:40 AM
> To: Ruby on Rails: Talk
> Subject: [Rails] Re: HowTo search a string for content?
>
>
> Hehe.. definetly a more simple way to do exactly that. Thank you
>
t: [Rails] Re: HowTo search a string for content?
Hehe.. definetly a more simple way to do exactly that. Thank you
Guess Reg Exp can probably define a more accurate pattern for email validation.
Thx
On Sep 10, 2:23 pm, "Pardee, Roy" <[EMAIL PROTECTED]> wrote:
> the o
Hehe.. definetly a more simple way to do exactly that. Thank you
Guess Reg Exp can probably define a more accurate pattern for email
validation.
Thx
On Sep 10, 2:23 pm, "Pardee, Roy" <[EMAIL PROTECTED]> wrote:
> the others are right to point you to regular expressions--definitely worth
> learn
the others are right to point you to regular expressions--definitely worth
learning.
But to give you a fish, you can use String's [] method to check for an @ symbol.
if my_string['@'] then
# my_string has an @ in it.
end
HTH,
-Roy
-Original Message-
From: rubyonrails-talk@goo
regular expressions on the menu today.
Cuz:
/(\(\d+\))?\s*(\d{3})(\s*-\s*)?(\d{4})/
Makes -200% sense to me currently
Thank you guys
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To
On 9 Sep 2008, at 21:24, David Liwoch <[EMAIL PROTECTED]> wrote:
>
> Obviously not a genius with Ruby.
>
> I simply want to check if the string from an form input is a phone
> number, or an email.
>
Read up on regular expressions
Fred
> I started testing wether the string.class was Bignum or
David,
I believe that regular expressions is what you may be looking for..
>> s = "(0045) 444-"
=> "(0045) 444-"
>> codes = s.match /(\(\d+\))?\s*(\d{3})(\s*-\s*)?(\d{4})/
=> #
>> codes[0]
=> "(0045) 444-"
>> codes[1]
=> "(0045)"
>> codes[2]
=> "444"
>> codes[4]
=> ""
hth..
Da
7 matches
Mail list logo