2012-01-25 139 views
0

我遇到了Yahoo管道的问题。雅虎管道:用RSS提要替换项目

我试图让位于在item.title(RSS供稿)结束的URL 我想用该网址在item.link

我使用正则表达式来获取网址(((f | ht){1} tp://)[-a-zA-Z0-9 @:%_ +。〜#?& // =] +),并且工作正常。

但是我如何使用它来为item.link使用它?

现在看起来是这样的:

.. 
<item> 
<title> 
Hello this is a test http://www.google.com 
</title> 
<link> 
http://otherurl 
</link> 
<description> 
Hello this is a test http://www.google.com 
</description> 
<guid isPermaLink="false"> 
http://otherurl 
</guid> 
<pubDate>Tue, 24 Jan 2012 18:27:18 +0000</pubDate> 
</item> 
.. 

我想让它像这样:

.. 
<item> 
<title> 
Hello this is a test http://www.google.com 
</title> 
<link> 
http://www.google.com 
</link> 
<description> 
Hello this is a test http://www.google.com 
</description> 
<guid isPermaLink="false"> 
http://otherurl 
</guid> 
<pubDate>Tue, 24 Jan 2012 18:27:18 +0000</pubDate> 
</item> 
.. 

回答

0

使用Regex moduleitem.title复制到item.link的再修改item.link

1)在item.link中将.*替换为${title}

2)item.link更换".* "(不包括引号,注意最后用""(空)

+0

Tnx,快速响应。我现在可以将整个item.title复制到item.link,但是我如何只提取url(您提供的步骤2)?我可以给你的管道:[链接](http://pipes.yahoo.com/pipes/pipe.info?_id=f02b441f7afeed3563bbc90fa7034f1f) – Jan

+0

与正则表达式的问题是,我可以找到并选择的网址,但我可以不提取它。首先我做一个:RENAME item.description copyas linkje。然后REGEX item.linkje用$ 1替换(((f | ht){1} tp://)[-a-zA-Z0-9 @:%_ \ +。〜#?&// =] +) 。但是我仍然得到了整个句子,而不仅仅是url。我怎样才能更改代码,所以我只能显示网址? – Jan

+0

添加了一个正则表达式来提取URL。注意:仅适用于简单情况“某些带有空格的文本http://example.com” –

0

的空间),我找到了!它应该是

^.*(((f|ht){1}tp://)[[email protected]:%_\+.~#?&//=]+).*$ 

它会选择一切,直到它找到一个网址!