regexp module with submatches available

Robert Virding <>
Mon Mar 26 17:34:52 CEST 2001

Pascal Brisset <> writes:
>Robert Virding writes:
> > Having a call to just match and extract the groups would probably be
> > useful.  The question is whether to return the actual substrings or
> > return a list of start/length pairs like match does today.
>Actually, gregexp:groups just maps lists:sublist/3 over a list of
>start/length pairs returned by gregexp:re_apply/3.
>Why not export re_apply/3 ? I'd rather use it than match/2, which
>seems to iterate over the whole string to find the first match.

Probably will, at the moment I am in a mood to open up some of the
library modules, done erl_eval for Joe and probably do shell as well.
So there maybe will be a re_apply/3 for those who want to
roll-there-own and some highere interfaces for the standard uses.

There are also some bug fixes.

>From the manual

       match(String, RegExp) -> MatchRes

              Finds  the  first,  longest  match  of  the regular
              expression RegExp in String. This function searches
              for  the  longest  possible  match  and returns the
              first one found if there are several expressions of
              the same length.

       first_match(String, RegExp) -> MatchRes

              Finds the first match  of  the  regular  expression
              RegExp  in String. This call is usually faster than
              match and it is also a useful way to ascertain that
              a match exists.

That minus some uninteresting junk about arguments, return values and
errors.  :-)


More information about the erlang-questions mailing list