Ruby on Rails
Monday, December 27, 2010
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.
-Rob
Rob Biedenharn
Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment