re = /{[^}]*name:[^}]*\bthe\b[^}]*}/i
str = '{
id: 1
locID: A
tStart: 17:10:00
tEnd: 17:35:00
name: the man 45
text: Lorum Ipsum
}
{
id: 2
locID: A
tStart: 17:11:00
tEnd: 17:12:00
name: Frank
text: Lorum Ipsum
}
{
id: 3
locID: A
tStart: 17:11:00
tEnd: 17:14:00
name: there Frank
text: Lorum Ipsum
}
{
id: 4
locID: B
tStart: 17:51:00
tEnd: 17:56:00
name: the woman 2
text: Lorum Ipsum
}
{
id: 5
locID: A
tStart: 17:11:00
tEnd: 16:11:00
name: the man with the golden gun
text: Lorum Ipsum
}
{
id: 6
locID: C
tStart: 17:11:00
tEnd: 17:11:00
name: the woman with the dragon tattoo
text: Lorum Ipsum
}
{
id: 7
locID: A
tStart: 17:15:00
tEnd: 17:15:00
name: Jo
text: Lorum Ipsum
}'
# 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