• REGISTRATION REQUIREMENTS:

    Your username here MUST MATCH your XenForo username (connected to your XF license).

    Once you have registered here, then you need to start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

RegEx Examples for Custom Fields

MattW

Server Admin
AMS Premium
CAS Premium
RMS Premium
SC Premium
UBS Premium
For 2 of my custom fields, I'm using Regular Expression to make sure they are formatted correctly, and that members can't take the piss with them (BHP and Torque)

For this, I'm limiting them to < 999.99 bhp and lb/ft and they can enter upto 2 decimal places, or whole number

This is the regex I'm using:

Code:
^\d{2,3}\.?\d{0,2}?$

^ - start of anchor
\d - Numbers
{2,3} - between 2 and 3 numbers in length
\.? - escaped the decimal place, and set it as optional with ?
\d{0,2}? - 2 numbers after decimal place and also set optional with ?
$ - end of string anchor
 
and another one to correctly format the year (YYYY)
Code:
[1-2][0-9][0-9][0-9]
I only want them to be able to enter 1 or 2 for the first character. I could build it out and make it more specific, but hopefully my members aren't going to be that retarted ;)
 
  • Like
Reactions: Bob
Bit more customisation

additional_information.PNG

This is using the Value Display HTML to apply the extra formatting on the end of the value the member enters.

Nice and easy:
Code:
{$value} bhp
 
For 2 of my custom fields, I'm using Regular Expression to make sure they are formatted correctly, and that members can't take the piss with them (BHP and Torque)

For this, I'm limiting them to < 999.99 bhp and lb/ft and they can enter upto 2 decimal places, or whole number

This is the regex I'm using:

Code:
^\d{2,3}\.?\d{0,2}?$

^ - start of anchor
\d - Numbers
{2,3} - between 2 and 3 numbers in length
\.? - escaped the decimal place, and set it as optional with ?
\d{0,2}? - 2 numbers after decimal place and also set optional with ?
$ - end of string anchor
Question on this regex - is it set to allow 0 or 2 numbers after the decimal point?
 
Is there a way of converting 60362 to 60,362, adding the comma, using regex. This isn't something I'm very good with.
 
Back
Top