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.