我有一个像下面这样一个字符串:红宝石先进GSUB
My first <a href="http://google.com">LINK</a>
and my second <a href="http://yahoo.com">LINK</a>
如何替换此字符串中的所有环节,从HREF =“URL”到HREF =“/重定向URL =网址是什么? “,使它变成
My first <a href="/redirect?url=http://google.com">LINK</a>
and my second <a href="/redirect?url=http://yahoo.com">LINK</a>
谢谢!
你不觉得你欠OP的正则表达式的解释吗?我建议你把它写成多行'r = /.../ x',这样你可以包含注释,然后'str.gsub(r)'。我的答案[这里](http://stackoverflow.com/questions/29216618/consistently-separate-values-in-array/29218517#29218517)给出了一个例子。 – 2015-04-05 21:06:36
@CarySwoveland我的不好,补充说明。 – 2015-04-05 22:41:21
这次你被原谅了。 – 2015-04-06 00:06:44