[erlang-questions] Improved regexp.erl

Fredrik Thulin ft@REDACTED
Thu Oct 26 08:39:53 CEST 2006


Robert Virding <robert.virding@REDACTED> wrote:
...
> What requirements do people have?

In YXA, we still have a modified regexp.erl (modified by Magnus Ahltorp 
a long long time ago) that can return a list of all groups in a match. 
Example :

  1> group_regexp:groups("foobar", "foo(.+)").
  {match,["bar"]}
  2>

This we then use to perform substitutions, so that in the end the 
following is possible :

  3> L.
  [{"^0000([1-9].+)$","+\\1"},
   {"^000([1-9].+)$","+46\\1"},
   {"^00([1-9].+)$","+468\\1"}]
  4> util:regexp_rewrite("000319876543", L).
  "+46319876543"
  5> util:regexp_rewrite("00162000", L).
  "+468162000"
  6>

Maybe there is a way to do it with the current regexp.erl (the one in 
R11B-1 I mean), in which case I would like to know about it =) but if 
there isn't then that is a requirement for me.

Many thanks

/Fredrik




More information about the erlang-questions mailing list