re = /(?<=vol": ').*(?=',\s*"tvr)/m
str = 'M18.r_16981 = {
"ltt": \'2018/06/21 11:43\',
"np": \'0.050\',
"iep": \'0.000\',
"iev": \'0\',
"ltp": \'0.050\',
"vol": \'940000\',
"tvr": \'49860\',
"dyh": \'0.060\',
"dyl": \'0.049\'
};'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html