Rails regex to fetch Twitpic link / code if present

The URL is provided in a line of text (tweet) like

"Check out my twitpic http://twitpic.com/1876544594 its awesome

I need a Rails regex that will return 18744594, the id of this particular twitpic ...

This question was asked here but was for PHP and I need it for Rails.

I would and could get the name of the site, so the text between the http: // and .com "twitpic"

+2


a source to share


1 answer


To extract 18744594

only

/http:\/\/twitpic\.com\/(\d+)/

      



To extract twitpic

and18744594

/http:\/\/(twitpic)\.com\/(\d+)/

      

+4


a source







All Articles