我正在尝试为 win 7 创建一个小工具,用于从站点检索 RSS 提要。到目前为止一切都很好,只是我想添加一些额外的东西。到目前为止,小工具从提要中提取链接并将其存储在名为“articlelink”的变量中,该链接通常类似于“http://site.ro/film/2009/brxfcno-/22462" 或 "http://site.ro/serial/2004/veronica-mars---sez-3/1902"。
此变量用于在按下小工具窗口中的链接时出现的弹出窗口标题中创建链接。
我需要的是一段代码,用于提取末尾的数字(22462, 1902)并将其存储在另一个变量中,以便我可以用它创建一个新链接,该链接可以作为单独的链接显示在弹出窗口中。
示例
初始链接
http://site.ro/serial/2004/veronica-火星---sezonul-3/1902
新链接
http://site.ro/get/1902
I'm trying to create a gadget for win 7, that retrieves the RSS feed from a site. So far so good, everything works fine, just that I want to add something extra. The gadget so far extracts the link from the feed and stores it in a variable named 'articlelink', the link is usually something like "http://site.ro/film/2009/brxfcno-/22462" or "http://site.ro/serial/2004/veronica-mars---sez-3/1902".
This variable is used to create a link in the title of the flyout window that appears when the link in the gadget window is pressed.
What I need is a piece of code that extracts the number at the end (22462, 1902) and stores it in another variable so I can create a new link with it, which can be displayed in the flyout window as a separate link.
Example
initial link
http://site.ro/serial/2004/veronica-mars---sezonul-3/1902
new link
http://site.ro/get/1902
发布评论
评论(3)
下面回答 Splash 的问题:
Answering Splash's question below:
您可以提取
子字符串
,获取最后一个/
和结尾之间的字符:You can extract a
substring
, to get the characters between the last/
and the end:获取字符串最后一部分的习惯用法:
比 CMS 的版本可读性稍好,但代价是速度稍慢。
An idiom for getting the last part of a string:
Slightly more readable than than CMS's version, at the cost of being somewhat slower.