Regex for custom profile fields

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
Doldol
Registered User
Posts: 1
Joined: Mon Jul 30, 2012 8:28 pm

Regex for custom profile fields

Post by Doldol »

Now custom profile fields offer very limited options to limit what's put into them:
- Maximum/Minimum number of characters
- Field validation

I suggest an advanced option of allowing a regex (with preg_match()) to be defined for it.
So that you have greater flexibility in limiting the fields.


Example case:
Users are supposed to only be able to enter a Steam ID.
- starts with STEAM_0:
- followed by either a 0 or 1.
- followed by a :
- followed by an integer 3 to 8 numbers in length.
Example: STEAM_0:1:1579421

Code: Select all

$re = "/^STEAM_0:[01]:[0-9]{3,8}$/"
Currently the closest you can get to this is setting the maximum and minimum amount of characters.

Post Reply