From: D T Date: 2003-06-25T03:50:52+09:00 Subject: Re: CAN find appropriate regexp ;-)) --0-60179810-1056480645=:56822 Content-Type: text/plain; charset=us-ascii You are welcome. Yesterday, I though I did saw somewhere about this is classic question; that's right, it is in the "Mastering Regular Expression" book. After check, the solution on the book is just like what I came out, but in the book, they gave other one for more performance: /"(?:[^\\"]+|\\.)+"/ # did you see the different? :-) BTW: if you like to match empty string like "" you can change to /"(?:[^\\"]+|\\.)*"/ You can check the book for more information. Dave Patrick Zesar wrote: > str = <<'EOF' > foo "foobar" > bar "foo" "bar"; > fob "foo \"bar\""; > EOF > str.each_line{ |line| > p line.scan(/"(?:[^\\"]|\\.)+"/).collect! {|e| e.sub!(/^"(.*)"$/, '\1')} > } > > It seems to me that works. thanx - that's perfect i wasn't aware of the '?:'-thing - i'm still not sure what it does exactly - but it's working ;-)) thanx again, patrick --------------------------------- Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! --0-60179810-1056480645=:56822 Content-Type: text/html; charset=us-ascii
You are welcome.
 
Yesterday, I though I did saw somewhere about
this is classic question; that's right, it is in the
"Mastering Regular Expression" book.
 
After check, the solution on the book is just like
what I came out, but in the book,
they gave other one for more performance:
 
/"(?:[^\\"]+|\\.)+"/  # did you see the different? :-)
 
BTW: if you like to match empty string like "" you can
change to
/"(?:[^\\"]+|\\.)*"/ 
 
You can check the book for more information.
 
Dave
 
Patrick Zesar <jonnypichler@gmx.net> wrote:
> str = <<'EOF'
> foo "foobar"
> bar "foo" "bar";
> fob "foo \"bar\"";
> EOF
> str.each_line{ |line|
> p line.scan(/"(?:[^\\"]|\\.)+"/).collect! {|e| e.sub!(/^"(.*)"$/, '\1')}
> }
>
> It seems to me that works.

thanx - that's perfect

i wasn't aware of the '?:'-thing - i'm still not sure what it does exactly -
but it's working ;-))

thanx again,
patrick



Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month! --0-60179810-1056480645=:56822--