Erlang re:run regular exp, match problrm

Mathias <>
Sat Oct 30 12:44:47 CEST 2010


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