0
我有一个字符串,它类似于此:正则表达式来查找字符串两个URL
|image: http://product_image.png |product: http://product_url.html
所以,图案|图片:网址|产品:URL
我怎样才能找到这些Ruby中有两个URL?
我有一个字符串,它类似于此:正则表达式来查找字符串两个URL
|image: http://product_image.png |product: http://product_url.html
所以,图案|图片:网址|产品:URL
我怎样才能找到这些Ruby中有两个URL?
试试这个正则表达式:
regex = /image: (.+) \|product: (.+)/
result = regex.match("|image: http://product_image.png |product: http://product_url.html")
puts result[1] # http://product_image.png
puts result[2] # http://product_url.html