> On Fri, Feb 11, 2011 at 11:30 AM, Rodrigo Alves Vieira <[email protected]> > wrote: > Hello everyone, in my Rails app I need to validate a string that on creation > can not have its first chars empty or composed by any special chars. > > For example: " file" and "%file" aren't valid. Do you know what Regex I > should use? > > You could utilize the "anchor" for this -- that is you say that the line must > "begin" with the characters that match the following regex. > Something like: /\A[\w]+$/ would work.
Note that \w will match an underscore. Don't know if you consider that "special" or not... -- 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.

