re = /(?:\bmembers\s*\{|(?<!^)\G[^{]+\{[^}]+\})\s*?\n\s*([^:{}]+)(?=:\d)/
str = 'ltm pool TEST_POOL {
Some strings
above headers
records {
baz:1 {
ANY STRING
HERE
}
foobar:23 {
ALSO ANY
STRING HERE
}
}
members {
qux:45 {
ALSO ANY
STRINGS HERE
}
bash:2 {
AND ANY
STRING HERE
}
topaz:789 {
AND ANY
STRING HERE
}
}
Some strings
below headers
}'
# 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