开发者

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

开发者 https://www.devze.com 2023-04-09 12:14 出处:网络
Here is my pipe: http://pipes.yahoo.com/pipes/pipe.info?_开发者_StackOverflow中文版id=a732be6cf2b7cb92cec5f9ee6ebca756

Here is my pipe: http://pipes.yahoo.com/pipes/pipe.info?_开发者_StackOverflow中文版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

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

AFTER REGEX

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

Trying to check the g symbol

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号