String processing - regex

Laurent Picouleau laurent.picouleau@REDACTED
Mon Jun 13 15:22:13 CEST 2005

Hi Eranga,

On Sat, 2005-06-11 at 02:52, casper2000a@REDACTED wrote:
> Hi Laurent,
> Thanks for the info. But I tried that too,
> gregexp:groups("<mod:fun(arg1, arg2, arg3, arg5,arg6)>", "<\\(.+\\):\\(.+\\)[(]\\(.+\\)(,[\s]*\\(.+\\))*[)]>").
>    --> {match,["mod","fun","arg1"," arg2"," arg3"," arg5","arg6"]}
> The result I get then have a space infront of arg2, arg3 and arg5. I want to get rid of any spaces in 
> front. Ofcourse I can trim manually, but I'm sure there must be a way to get that done in one parse 
> using regexp.

This is more a regex problem than an erlang problem IMHO. You could do
it like with this regex:
"<\\(.+\\):\\(.+\\)[(]\\(.+\\)(,[\s]*\\([^ ]+\\))*[)]>"

Here I've used anything but space ( [^ ] ) but ideally you would like to
have anything but \s. See the documentation of this particular regex
language to have the expected behaviour.


Laurent Picouleau

More information about the erlang-questions mailing list