Regular expressions From Online Manual

Revision as of 21:43, 26 March 2013 by HappyBits (talk | contribs) (Regular expressions in SMF must be delimited in order to be evaluated)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In Custom Profile Fields the Input Mask can be set to 'Regex (Advanced)', which then allows you to enter a regular expression that you would like to use to validate that profile field. However, the regex that you enter must be delimited by special characters. If you simply enter a regex, like this:

[12][0-9]{3}

it doesn't work. Even worse, it fails silently, acting as though any data that was entered is matched by the regex.

If you enter the regex surrounded by tildes, as shown by [emanuele], or like this:

~[12][0-9]{3}~

then it works as expected. Double quotes also work as delimiters.

Tested in SMF 2.0.4.



Advertisement: