Yahoo Pipes和regex:为什么它仅适用于我的第一件商品? [英] Yahoo Pipes and regex: Why does it work only for my first item?

查看:108
本文介绍了Yahoo Pipes和regex:为什么它仅适用于我的第一件商品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的烟斗: http://pipes.yahoo.com/Pipes/pipe.info?_id = a732be6cf2b7cb92cec5f9ee6ebca756

我目前正在尝试在item.url的第一个空格之前获得该部分,第二个部分将成为标题.

I am currently trying to get the part before the first space to my item.url and the second part will be the title.

例如,第一项是:

http://carto1.wallonie.be/documents/terrils/fiche_terril.idc?TERRIL_id=1 Crachet 7/12

预期的结果是将"Crachet 7/12"作为标题,而将另一部分作为链接.

The expected result would be to get the "Crachet 7/12" as title and the other part as link.

我的正则表达式查询"([^\s]+)"似乎仅适用于我的第一个项目,我不明白为什么,因为所有项目的格式都相同.

My regex query "([^\s]+)" seem to work only for my first item, I don't understand why, as all the items are formatted the same way.

非常感谢您的帮助!

图片以更好地理解:

正则表达式前

后正则表达式

尝试检查g符号

推荐答案

您可以使用\S+代替[^\s]+.另外,您需要指定全局"标志,否则第一个成功匹配后正则表达式引擎将停止.为了仅匹配该行的第一个非空白部分,请在^锚中使用"multiline"标志:

You can use \S+ instead of [^\s]+. Also, you need to specify the "global" flag or the regex engine stops after the first successful match. In order to match only the first non-whitespace part of the line, use the ^ anchor with the "multiline" flag:

/^\S+/gm

new RegExp("^\\S+", "gm")

根据您的情况,您需要选中相应的复选框.

In your case, you need to check the appropriate checkboxes.

这篇关于Yahoo Pipes和regex:为什么它仅适用于我的第一件商品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆