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 Fixnum. If it
> was I presumed it was a phonenumber. Although this works in script/
> console, my application dosn't seem to pass the Bignum and Fixnum
> tests and proceeds to the else statement.
>
> So now I wanna try looking for the content in my string.
>
> I thought, hey, ill just look for the "@" sign in the posted string.
> But how? I've been searching for several hourse. And don't seem to run
> into any solution.
>
> So I'll go to bed, and cross my fingers.
>
> Thx in advance
>
> Btw, this is what I'm trying:
>
> I'm using a phonenumber or the email as login. Same field.
> If the user enters his phonenumber, I wanna make sure it works weather
> the user types:
>
> 0045xxxxxxxx
> 45xxxxxxxx
>
> (0045) Danish area code.
>
>
> def phone(input)
> unless input == ############## <------ unless what? Was
> thinking, unless @ in input.
> value = input.to_s
> lenStop = value.length
> lenStart = value.length - 8
> username = '45' + value[lenStart..lenStop]
>
> return username
> else
> return input
> end
> end
>
> I figure code dosn't work if user puts spaces in his phonenumber. I
> guess that can be fixed with a gsub " ", "".. something like that.
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---