I have been hacking on a way to only allow alphanumeric, dots (.), dashes (-) and underscores (_) in usernames for my forum.

You may require the username to match a regular expression (PCRE). The admin help provides some examples that may be useful. To disable this function leave the option blank.

While looking at the PCRE, I thought this would work:

/^[A-Za-z0-9_\.\-]+$/

This would not work as I planned.

Solution:

The solution was subtle:

^[A-Za-z0-9_\.\-]+$

I needed to remove the backslashes (/) from the beginning and the end of the regular expression.

I also added the following Illegal User Names:

.. __ --

complete.

Mick Knutson

Java, JavaEE, J2EE, WebLogic, WebSphere, JBoss, Tomcat, Oracle, Spring, Maven, Architecture, Design, Mentoring, Instructor and Agile Consulting. http://www.baselogic.com/blog/resume

View all posts

Java / JavaEE / Spring Boot Channel

BLiNC Supporters

BLiNC Adsense

Archives

Newsletter