Yahoo Pipes and regex: Why does it work only for my first item?

偶尔善良 提交于 2019-12-11 08:20:52

问题


Here is my pipe: http://pipes.yahoo.com/pipes/pipe.info?_id=a732be6cf2b7cb92cec5f9ee6ebca756

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

For instance, first item is:

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

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

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.

Thank a lot for any help!

EDIT: Pictures to understand better:

BEFORE REGEX

AFTER REGEX

Trying to check the g symbol


回答1:


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

or

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

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



来源:https://stackoverflow.com/questions/7596250/yahoo-pipes-and-regex-why-does-it-work-only-for-my-first-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!