From: "Wolfgang Nádasi-donner" Date: 2007-07-31T04:50:20+09:00 Subject: Re: Finding un-escaped characters in scan() Fred Phillips wrote: > I have a string that looks like this: "test,,\,test". And I'm trying to > count the commas which don't follow a \. But when using scan(/[^\\],/) > it > only finds the first comma. I think this is because after scan() has > found a > comma without a backslash, it continues from where it left off, and > since > there's no character before the next comma, it won't match it. Does > anyone > know how to fix it? If you can use Ruby 1.9, you simly can express it using 'negative look behind': irb(main):001:0> "test,,\\,test".scan(/(? [",", ","] irb(main):002:0> "test,,\\,test,test2,\\,test3".scan(/(? [",", ",", ",", ","] Wolfgang Nádasi-Donner -- Posted via http://www.ruby-forum.com/.