re = /^Content-Type: \K.+/m
str = 'HTTP/1.1 200 OK
Date: Mon, 17 Jun 2019 19:32:37 GMT
Server: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.2.15
X-Powered-By: PHP/7.2.15
Set-Cookie: Avisistema=ihk9t1ms6r8i0u1j5t6jpjrqei; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: Avisistema=ihk9t1ms6r8i0u1j5t6jpjrqei; expires=Tue, 18-Jun-2019 03:32:37 GMT; Max-Age=28799; path=/; HttpOnly
Set-Cookie: SageFirmeware=Avisistema.A.0.2015.01.10; expires=Tue, 18-Jun-2019 03:32:37 GMT; Max-Age=28799; path=/; HttpOnly
Content-Length: 232
Content-Type: application/json
Some-Garbage: test string'
# Print the match result
str.match(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