user1819172
user1819172

Reputation: 21

preg_match+multi patterns

I want to change this code

$reg_exUrl = "/imageshack/";
if(preg_match($reg_exUrl, $imageURL, $url))

so it will check fro more than one site, like

"/imageshack/,/photobucket/";

I'm noob in php!

Upvotes: 2

Views: 5607

Answers (1)

opatut
opatut

Reputation: 6864

In regular expressions, to select an option of multiple choices, use the (|) snytax:

$reg_exUrl = "/(imageshack|photobucket)/";
if(preg_match($reg_exUrl, $imageURL, $url))

Notice how the / are only regex delimiters, not part of the matched pattern.

Upvotes: 7

Related Questions