SMF Support > SMF 2.0.x Support

Custom Field and Regex


Is this a complete feature or am I just doing something wrong with regex or expecting it to do something it does not do?

I set the field to regex, so I could filter wii friend codes for my community, with
([0-9]{4})\ ([0-9]{4})\ ([0-9]{4})\ ([0-9]{4})

I put data in my profile on the forum with both of these data sets,

1111 2222 3333 4444
1111 2222 3333 DDDD

They both passed, did not kick an error, bug?

Should it kick back an error if the entry does not match the regex?

It should just set it to an empty string if it doesn't match...


--- Code: (Lines 1237-1238) --- elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
$value = '';
--- End code ---

Did I screw up in the regex statment then? 4 groups of 4 numbers is what it should be.

I believe your missing a pattern delimiter
@([0-9]{4})\ ([0-9]{4})\ ([0-9]{4})\ ([0-9]{4})@

I used @ but some people use # or ~ or other characters as pattern delimiter.

That did it.


[0] Message Index

Go to full version