re = /(?<=Set-Cookie: __RequestVerificationToken=).{108}/m
str = 'HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Set-Cookie: __RequestVerificationToken=6JBpdPLoWg2ON0CbCTTCffsZZsCU_rRGlmarVTRfg4Gu1_6FEqpgd_jcLbN_mBWdXJjCeYw6DQ3nxd8hABsNTpRWJALapk9KUZhu6jGkh0I1; path=/; HttpOnly
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
strict-transport-security: max-age=60; includeSubDomains
referrer-policy: strict-origin-when-cross-origin
Set-Cookie: httpOnly
X-Content-Security-Policy: script-src \'self\' https://fonts.gstatic.com
Date: Wed, 12 Feb 2020 15:46:34 GMT
Content-Length: 3124'
# 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