Reputation: 2520
Good sirs.
I seem to have a decent regex to capture the url I want...
So how am I using it wrong?
2.0.0-p451 :237 > resbody
=> "{"provider_url": "http://www.popsci.com", ...
2.0.0-p451 :240 > resbody.match(/"thumbnail_url":"([^"]*)"/)
=> nil
2.0.0-p451 :241 > resbody.scan(/"thumbnail_url":"([^"]*)"/)
=> []
2.0.0-p451 :242 > resbody[/"thumbnail_url":"([^"]*)"/,1]
=> nil
Upvotes: 0
Views: 45
Reputation: 106972
That string looks like JSON. Therefore the following should return the what you need:
require 'json'
JSON.parse(resbody)['thumbnail_url']
Upvotes: 1