Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: TLM on April 19, 2008, 11:33:29 AM

Title: Custom Field and Regex
Post by: TLM on April 19, 2008, 11:33:29 AM
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?
Title: Re: Custom Field and Regex
Post by: Oldiesmann on April 19, 2008, 05:18:45 PM
It should just set it to an empty string if it doesn't match...

Sources/Profile-Modify.php
Code (Lines 1237-1238) Select
elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
$value = '';
Title: Re: Custom Field and Regex
Post by: TLM on April 19, 2008, 05:30:27 PM
Did I screw up in the regex statment then? 4 groups of 4 numbers is what it should be.
Title: Re: Custom Field and Regex
Post by: karlbenson on April 19, 2008, 05:53:24 PM
I believe your missing a pattern delimiter
eg
@([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.
Title: Re: Custom Field and Regex
Post by: TLM on April 19, 2008, 07:10:48 PM
That did it.