Thanks for all help!

On 12 Aug, 15:34, Juan Alvarado <[email protected]> wrote:
> On Aug 12, 2011, at 9:21 AM, Colin Law wrote:
>
> > On 12 August 2011 14:08, Niklas Nson <[email protected]> wrote:
> >> I need to validate a string from a user (a location for use with
> >> geotagging) that is. I want to make sure that the user specify a city
> >> and a country in my inp ... So i wrote this =>
>
> >>  validates :usri_location,
> >>            :presence => true,
> >>            :format => {:with => /^[a-zA-Z]+{\,\s}+[a-zA-Z]/i},
>
> You have {} instead of () around the , and \s.  Also, I don't believe the ',' 
> has to be escaped (it didn't work with it escaped and it does if i remove the 
> escaping.  With those 2 issues fixed it works for me on rubular.
>
>
>
>
>
>
>
>
>
> >>            :on => :create
>
> >> I want to make sure that the user writes city, country
>
> >> city + ", " + country
>
> >> but all i get is (invalid) some one with more experience with regex
> >> wanting to help out or show me in a direction.
>
> > The way I tackle this sort of problem is to start with a simple regex
> > and slowly build it up.  So you could start with just expecting alpha
> > characters and check that it accepts the city ok, then add the
> > expected comma, and so on.
>
> > Colin
>
> > --
> > 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 
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
> Juan Alvarado

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

Reply via email to