Erik Pearson <>
Mon Nov 19 20:05:18 CET 2001

I think the documentation could be made much clearer.

My experience is that regexp:match selects the longest
match when the match can start at *different* positions
in the string.  Keep in mind, a match at any given
position is *always* the longest match.

In Niels' case,

2> regexp:first_match("<DATE>22-03-03</DATE>","<.+>").

There are two matches in the string:


But because of greediness there is no match
for the first 6 characters; they're consumed
in the first match case.

To see the difference with match and first_match,
try adding an optional pattern to differentiate
the longest from the first match.

1> regexp:match("12123", "123?").
2> regexp:first_match("12123", "123?").


-----Original Message-----
From: Bengt Kleberg [mailto:]
Subject: Re: regexp:first_match 

According to the documentation
will get thet longest match, exactly as you state.

is documented as only matching the first match (which should be the one
Christensen wanted).


More information about the erlang-questions mailing list