开发者

Rails regex to extract Twitpic link/code if present

开发者 https://www.devze.com 2022-12-28 04:58 出处:网络
Provided a url, within a string of text (tweet) such as \"Check out my twitpic http://twitpic.com/1876544594 its awesome\"

Provided a url, within a string of text (tweet) such as

"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 has been asked here but was for PHP, and I need it for Rails.

I would also be able to pull the n开发者_运维技巧ame of the site, so the text between http:// and .com "twitpic"


To extract 18744594 only

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

To extract twitpic and 18744594

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

精彩评论

暂无评论...
验证码 换一张
取 消