繁体   English   中英

正则表达式内的数字长度不确定

[英]Number length undetermined inside regex

我这行与正则表达式:

user.image.gsub(%r{(http://graph.facebook.com/\d{15}/picture\?type=)\w+}, '\1large')

个人资料图片网址可以是:

http://graph.facebook.com/12/picture?type=square
http://graph.facebook.com/123/picture?type=square
http://graph.facebook.com/1234/picture?type=square
http://graph.facebook.com/12345679/picture?type=square

URL中的length number不确定。

如何使用此正则表达式匹配此URL中的任何长度数字?

我尝试过:

user.image.gsub(%r{(http://graph.facebook.com/\d/picture\?type=)\w+}, '\1large')

但它不起作用。

user.image.gsub(%r{(http://graph.facebook.com/\d+/picture\?type=)\w+}, '\1large')
                                 add a + here __^

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM