On Thu, 21 Dec 2006, Bil K. wrote:
embarrassingly hideous.
easy:
harp:~ > cat a.rb
a = 'variables="x", "y", "z", "rho", "u", "v", "w", "p/pinf", "s",
“mach”’
variables = eval a
p variables
harp:~ > ruby a.rb
["x", "y", "z", "rho", "u", "v", "w", "p/pinf", "s", "mach"]
hard:
harp:~ > cat a.rb
a = ‘variables=“x”, “y”, “z”, “rho”, “u”, “v”, “w”, “p/pinf”, “s”,
“mach”’
re = %r/
“([^”\](?:\.[^"\]))" # matches balanced double quotes
|
‘([^’\](?:\.[^‘\]))’ # matches balanced single quotes
/ox
variables = a.scan(re).map{|a,b| a || b}
p variables
harp:~ > ruby a.rb
[“x”, “y”, “z”, “rho”, “u”, “v”, “w”, “p/pinf”, “s”, “mach”]
info:
http://rubyforge.org/pipermail/bdrg-members/2006-June/000050.html
cheers.
-a