Reputation: 4023
I'm trying to match a certain string of the url using preg_match
but I need to match either one or the other string and I can't find the correct syntax.
What I'm using now is:
$is_url_en = preg_match ("/\b95\b/i", $iframeurl);
This searches for the number "95" in the url. However I also want to match "en" as well but I don't know how to use the 'or' delimiter. I've seen somewhere the following:
$is_url_en = preg_match ("/\b95\b/i|/\ben\b/i", $iframeurl);
...but it doesn't work. Any hints please?
Upvotes: 0
Views: 669
Reputation: 361909
Don't repeat the /
and /i
. Those delimit the regex so they should only be there once.
$is_url_en = preg_match ("/\b95\b|\ben\b/i", $iframeurl);
You could then simplify this to:
$is_url_en = preg_match ("/\b(95|en)\b/i", $iframeurl);
Upvotes: 5