Ruby on Rails Monday, December 27, 2010



On Mon, Dec 27, 2010 at 11:07 AM, Rob Biedenharn <Rob@agileconsultingllc.com> wrote:

On Dec 27, 2010, at 11:59 AM, David Kahn wrote:

It is the minus that is a special char (as in a-z) if you escape the
minus it is ok.

Yes I see you are right ---the weird part is that the minus is getting passed not as a special character in the first examples ( "Billy-Bob" =~ /^[a-zA-Z' -]*$/ returns 0!) .... anyhow, I will remember than and start escaping it.

The minus (hyphen) in a charset is un-special if it is at the beginning or the end. You're better off escaping it yourself for exactly the reason you encountered – adding another character to the end changed the meaning of the regular expression (charset) in a way you didn't expect.

Makes sense, thanks
 

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment