Advertisement:

Author Topic: Custom Field and Regex  (Read 2818 times)

Offline TLM

  • Full Member
  • ***
  • Posts: 420
  • Gender: Male
    • MindlessTux
Custom Field and Regex
« 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?

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,872
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Custom Field and Regex
« Reply #1 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 = '';
Michael Eshom
Cincy Space - now open!

Offline TLM

  • Full Member
  • ***
  • Posts: 420
  • Gender: Male
    • MindlessTux
Re: Custom Field and Regex
« Reply #2 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.

Offline karlbenson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,629
  • Gender: Male
    • Criminal Brief UK
Re: Custom Field and Regex
« Reply #3 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.

Offline TLM

  • Full Member
  • ***
  • Posts: 420
  • Gender: Male
    • MindlessTux
Re: Custom Field and Regex
« Reply #4 on: April 19, 2008, 07:10:48 PM »
That did it.