[erlang-questions] Erlang re:run regular exp, match problrm
dlfen
erlangdlf@REDACTED
Sat Oct 30 13:03:44 CEST 2010
try this.
re:run("<point x=\"12\" y=\"2\" z=\"4\"/><point x=\"4\" y=\"2\" z=\"14\"/>", "<point[^<point]*\/>",[global]).
在 2010-10-30,下午6:44, Mathias 写道:
> Hi there,
>
> I'm trying to figure out how Erlangs re:run module works.
>
> When executing this::
> 1> re:run("<point x=\"12\" y=\"2\" z=\"4\"/><point x=\"4\" y=\"2\"
> z=\"14\"/>", "<point(?:\s|.)*\/>").
> {match,[{0,54}]}
>
> I can see that it gives me a match on the complete XML representation
> {match,[{0,54}]}.
>
> But what I really would like to do is for it to give me a subset of matches
> on each entity similar to {match,[{0,26},{27, 26}]}.
>
> so the output would yield something like this:
> 0-26 gives the first xml entity complete with it's attributes <point x="12"
> y="2" z="4"/> and
> match 27,26 gives the remaining entity.
>
> If anyone can spot why my regexp:<point(?:\s|.)*\/> is failing and guide me
> in the right direction closer to find the solution it will be greatly
> appreciated.
>
> I know about xmerl but for my trivial case it seems like overkill.
>
> Thx in advance.
>
> BR,
> Mathias Stalås
More information about the erlang-questions
mailing list