MyBB Community Forums

Full Version: Unable to leave profile field blank if using Regex
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When I use a Regex in my configuration for a profile field it doesn't allow the user to submit an empty field. I've turned off the required field so users do not have to enter anything if they don't want to.

My Regex isĀ (^[a-zA-Z0-9 _\-,.[]+]+)
You are using some special characters which need to be escaped if you want them to be literals.

[ needs to be escaped as \[
] needs to be esacaped as \]
. needs to be escaped as \.
+ needs to be escaped as \+
\ needs to be escaped as \\
You may want to change the final + (meaning one or more) to * (meaning zero or more).
(^[a-zA-Z0-9 _\\-,\.\[\]\+]*)

Would that be correct?
Not quite. I think this would be correct though:
You can use this site to test your regex.
When using that regex, the tester doesn't pick up anything after I type ^ (which is good) but if I use it in MyBB, it allows me to update the profile field even if it contains a ^ symbol. I need to to disallow that symbol.
Try this instead: