Niels Christensen christen@REDACTED
Mon Nov 19 20:19:38 CET 2001

> According to the documentation
> regexp:match()
> will get thet longest match, exactly as you state.
> regexp:first_match()
> is documented as only matching the first match (which should be the one Niels 
> Christensen wanted).

It is a bit subtle. The somewhat unclear formulation
might be supposed to mean "find the first place you can start matching,
then match the longest possible sequence starting from there" which
is not the "first, longest" matching (because "longest" in the context of
regexp:match probably means globally longest (?)).

However, first_match is not even consistently greedy.
When using the expression "<.+>" in a long SGML file,
it sometimes matches just one tag, sometimes matches across several,
but not the whole file (as it could have).
I cannot find a simple example to illustrate the behaviour,
but it seems to prefer ending its match at newlines.


More information about the erlang-questions mailing list