re = /editor\s*\{[^{}"]*
# Notice that I enabled the \/x flag ----->
# That just allows me to add comments here to make it more readable
# Match from opening to closing double quote for the 'key'
"[^"]*"
# Then any whitespace between the 'key' and 'value'
\s+
# Match from opening to closing double quote for the 'value'
"[^"]*"/x
str = '"entity"
{
"id" "5040044"
"classname" "weapon_defibrillator_spawn"
"angles" "0 0 0"
"body" "0"
"disableshadows" "0"
"skin" "0"
"solid" "6"
"spawnflags" "3"
"origin" "449.47 5797.25 2856"
editor
{
"color" "0 0 200"
"visgroupshown" "1"
"visgroupautoshown" "1"
"logicalpos" "[-13268 14500]"
}
editor
{
"color" "0 0 200"
"visgroupshown" "1"
"visgroupautoshown" "1"
"logicalpos" "[-13268 14500]"
"specialchars" "}"
}
editor
{
"child" "0 0 200"
"visgroupshown" "1"
"visgroupautoshown" "1"
"logicalpos" "[-13268 14500]"
subgroup
{
"child" "42 42 42"
}
}
}
'
# 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