From: dblack@... Date: 2006-02-12T11:42:42+09:00 Subject: Re: Parse error within Regexp Hi -- On Sun, 12 Feb 2006, Mauricio Fernandez wrote: > On Sun, Feb 12, 2006 at 01:34:55AM +0900, Yukihiro Matsumoto wrote: >> |user@host:~$ ruby -e '"".scan / ,/' >> |-e:1: parse error, unexpected ',' >> |"".scan / ,/ >> | ^ >> |-e:1: unterminated string meets end of file >> >> |I suppose this is not the intended behaviour. What do you >> |think? >> >> Ruby interpreted '"".scan / ,/' as >> >> ("".scan) / ,/ >> >> i.e. the first slash was considered as a division operator. You need >> to tell Ruby that is a regular expression, by reforming the expression. > > Would something like this make sense? > > $ ./ruby19 -e '"".scan / ,/' > -e:1: syntax error, unexpected ',' > "".scan / ,/ > ^ > -e:1: unterminated regexp meets end of file > ======== I'm not sure the "unterminated string" makes sense as the error message, but I don't think it's an unterminated regex either. It seems that Ruby sees the first / as division, so it doesn't consider itself to be in mid-regex. If it thought it was in mid-regex, it would presumably keep going and it would find that the regex *is* terminated. I guess it's really a CommaDivisionError :-) David -- David A. Black (dblack@wobblini.net) Ruby Power and Light (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black