Registration Regexp

I'm trying to write a regexp for registration.
I want to require every user name to end with a certain postfix.

Something like this:

{acl, fruitname, {user_regexp, "-apple$"}}.
{acl, fruitname, {user_regexp, "-orange$"}}.
{access, register, [{allow, fruitname}]}.

I've tried many variations of escaping the dash, but I always get a denied request.
Sometimes the beam.smp process will cap the cpu, so clearly I'm on dangerous ground here.

Anyone have any regexp examples?

Working examples of regexp and glob

dfisher wrote:

I want to require every user name to end with a certain postfix.

The regexp should be something like:

{acl, fruitname, {user_regexp, ".*-apple$"}}.
{acl, fruitname, {user_regexp, ".*-orange$"}}.
{access, register, [{allow, fruitname}, {deny, all}]}.

Alternatively, instead of regexp you can use glob:

{acl, fruitname, {user_glob, "*-apple"}}.
{acl, fruitname, {user_glob, "*-orange"}}.
{access, register, [{allow, fruitname}, {deny, all}]}.

The old ACLs that you tried are probably stored in the internal database. You can delete them using the WebAdmin.

RE: Working examples of regexp and glob

Thanks, that worked.
I didn't realize that all the regex's I had tried were being stored in the database.
That was the cause of my problems.

Is user_glob more performant than user_regexp?
I read somewhere that erlang's regex implementation is pretty rough around the edges.

Syndicate content