[英]replace string in url with ruby regex
我在可變圖片中包含以下網址:
image = http://graph.facebook.com/111111111111111/picture?type=square
我想用正則表達式紅寶石替換這些網址的等號=
之后的最后一個字符串:
image = http://graph.facebook.com/111111111111111/picture?type=small
image = http://graph.facebook.com/111111111111111/picture?type=large
image = http://graph.facebook.com/111111111111111/picture?type=normal
111111111111111是15位數字。
我該怎么做?
非常感謝你!
s.gsub(%r{(http://graph.facebook.com/\d{15}/picture\?type=)\w+}, '\1replaced')
#=> "http://graph.facebook.com/111111111111111/picture?type=replaced"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.