admin管理员组文章数量:1023607
Here a string I need to parse using regex.
.idc?TERRIL_id=1 Crachet 7/12
In fact this is an url followed by 1 space and a text. I need to extract url and the text in 2 separate ways.
To extract the url \S+
is working just fine.
But to extract the text after first space, it gets really hard to understand.
I am using Yahoo Pipes. (I don't know if this link to edit the code will work)
EDIT:
Using (\S+) (.+) gives me something weird:
Here a string I need to parse using regex.
http://carto1.wallonie.be/documents/terrils/fiche_terril.idc?TERRIL_id=1 Crachet 7/12
In fact this is an url followed by 1 space and a text. I need to extract url and the text in 2 separate ways.
To extract the url \S+
is working just fine.
But to extract the text after first space, it gets really hard to understand.
I am using Yahoo Pipes. (I don't know if this link to edit the code will work)
EDIT:
Using (\S+) (.+) gives me something weird:
Share Improve this question edited Sep 29, 2011 at 15:37 Waza_Be asked Sep 29, 2011 at 14:37 Waza_BeWaza_Be 39.6k50 gold badges191 silver badges262 bronze badges 2- 3 Please always specify the language or tool you intend to use. Regex implementations vary, and a solution that works in one language may not work in another. – Tom Zych Commented Sep 29, 2011 at 14:39
- Thanks. Added in first post with link. – Waza_Be Commented Sep 29, 2011 at 14:42
1 Answer
Reset to default 4According to the Pipes documentation, it looks like it uses fairly standard regex syntax. Try this:
^(\S+)\s(.+)$
Then the URL will be $1 and the ment will be $2. The .
operator matches any character, which you will need since it looks like the ments may have spaces.
EDIT: changed from literal space to \s
since you might be looking at some odd whitespace character(s). You might as well throw a ^
and $
in there too, so the match fails instead of doing something weird.
Here a string I need to parse using regex.
.idc?TERRIL_id=1 Crachet 7/12
In fact this is an url followed by 1 space and a text. I need to extract url and the text in 2 separate ways.
To extract the url \S+
is working just fine.
But to extract the text after first space, it gets really hard to understand.
I am using Yahoo Pipes. (I don't know if this link to edit the code will work)
EDIT:
Using (\S+) (.+) gives me something weird:
Here a string I need to parse using regex.
http://carto1.wallonie.be/documents/terrils/fiche_terril.idc?TERRIL_id=1 Crachet 7/12
In fact this is an url followed by 1 space and a text. I need to extract url and the text in 2 separate ways.
To extract the url \S+
is working just fine.
But to extract the text after first space, it gets really hard to understand.
I am using Yahoo Pipes. (I don't know if this link to edit the code will work)
EDIT:
Using (\S+) (.+) gives me something weird:
Share Improve this question edited Sep 29, 2011 at 15:37 Waza_Be asked Sep 29, 2011 at 14:37 Waza_BeWaza_Be 39.6k50 gold badges191 silver badges262 bronze badges 2- 3 Please always specify the language or tool you intend to use. Regex implementations vary, and a solution that works in one language may not work in another. – Tom Zych Commented Sep 29, 2011 at 14:39
- Thanks. Added in first post with link. – Waza_Be Commented Sep 29, 2011 at 14:42
1 Answer
Reset to default 4According to the Pipes documentation, it looks like it uses fairly standard regex syntax. Try this:
^(\S+)\s(.+)$
Then the URL will be $1 and the ment will be $2. The .
operator matches any character, which you will need since it looks like the ments may have spaces.
EDIT: changed from literal space to \s
since you might be looking at some odd whitespace character(s). You might as well throw a ^
and $
in there too, so the match fails instead of doing something weird.
本文标签: javascriptRegex to get the text after first quotspacequotStack Overflow
版权声明:本文标题:javascript - Regex to get the text after first "space"? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745561966a2156215.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论