user2398188
user2398188

Reputation: 1477

pattern matching in arrays

I am hosting a forum running PHPBB software (written in PHP).

I added a 3rd party modification to my forum, that allows the user to add a link to their Facebook page in their profile. There is one line of code that checks the pattern of what the user enters in this text field, and displays an error if what the user enters doesn't meet the required pattern or format.

'facebook' => array(array('string', true, 12, 255),array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),

I'm baffled by the 2nd half of this line of code, and the specific pattern it's testing for. I can't find any PHP reference page to help me intrerpret the pattern it's testing for and also help me change it to my preferred pattern.

I'd like to modify the above line of code to reject any entry that doesn't begin with http://www.facebook.com/

Upvotes: 0

Views: 67

Answers (1)

user4035
user4035

Reputation: 23749

The following regexp checks, whether the string begins with http://www.facebook.com/ or https://www.facebook.com/:

'#^https?:\/\/www\.facebook\.com\/#i'

So, probably, your code should look like this:

array('match', true, '#^https?:\/\/www\.facebook\.com\/#i'))

Upvotes: 1

Related Questions