From: D T Date: 2003-06-25T04:53:40+09:00 Subject: Re: CAN find appropriate regexp ;-)) --0-2003196418-1056484417=:12613 Content-Type: text/plain; charset=us-ascii It works, if you try this test.rb # put it on a file and run by ruby not irb str = <<'EOF' "an escaped\" quote" "an escaped\\\" quote" EOF str.each_line{ |line| p line p line.scan(/"(?:[^\\"]+|\\.)+"/).collect! {|e| e.sub!(/^"(.*)"$/, '\1')} } For your example, I think the problem is on irb: try this on irb and you know what I mean. irb(main):001:0> '\\'.length 1 # see, it is 1 not 2, kind of in irb simple quote string still substitute \\ irb(main):002:0> Dave ahoward wrote: On Wed, 25 Jun 2003, D T wrote: > /"(?:[^\\"]+|\\.)+"/ # did you see the different? :-) /usr/home/howardat > irb irb(main):001:0> '"an escaped\" quote"' =~ /"((?:[^\\"]+|\\.)+)"/ && puts("(#{$1})") (an escaped\" quote) => nil irb(main):002:0> '"an escaped\\\" quote"' =~ /"((?:[^\\"]+|\\.)+)"/ && puts("(#{$1})") (an escaped\\) => nil this doesn't seem to work? -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ara.t.howard@noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 | ~ > ruby -e 'p(%.\x2d\x29..intern)' ==================================== --------------------------------- Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! --0-2003196418-1056484417=:12613 Content-Type: text/html; charset=us-ascii
It works, if you try this
test.rb  # put it on a file and run by ruby not irb
 
str = <<'EOF'
"an escaped\" quote"
"an escaped\\\" quote"
EOF
str.each_line{ |line|
  p line
  p line.scan(/"(?:[^\\"]+|\\.)+"/).collect! {|e| e.sub!(/^"(.*)"$/, '\1')}
}
 
For your example, I think the problem is on irb:
try this on irb and you know what I mean.
irb(main):001:0> '\\'.length
1  # see, it is 1 not 2, kind of in irb simple quote string still substitute \\
irb(main):002:0>
Dave

ahoward <ahoward@fsl.noaa.gov> wrote:
On Wed, 25 Jun 2003, D T wrote:

> /"(?:[^\\"]+|\\.)+"/ # did you see the different? :-)

/usr/home/howardat > irb

irb(main):001:0> '"an escaped\" quote"' =~ /"((?:[^\\"]+|\\.)+)"/ && puts("(#{$1})")
(an escaped\" quote)
=> nil

irb(main):002:0> '"an escaped\\\" quote"' =~ /"((?:[^\\"]+|\\.)+)"/ && puts("(#{$1})")
(an escaped\\)
=> nil

this doesn't seem to work?

-a
--
====================================
| Ara Howard
| NOAA Forecast Systems Laboratory
| Information and Technology Services
| Data Systems Group
| R/FST 325 Broadway
| Boulder, CO 80305-3328
| Email: ara.t.howard@noaa.gov
| Phone: 303-497-7238
| Fax: 303-497-7259
| ~ > ruby -e 'p(%.\x2d\x29..intern)'
====================================


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month! --0-2003196418-1056484417=:12613--