preg_match("/http:\/\/(w{3}.)?mydomain.com/i",$ref2
broken down:
match->
(starts with) [url]http://[/url]
(w{3}.)?
this matches a set , same as (www.)
the ? makes the set optional.. so what we have so far matches
either
[url]http://[/url]
or
http://www.
make a little more sense?
oh the w{3} just means match w{3 of them} its setup like
matchthis{min,max} so its:
a{1} matches "a"
a{2} matches "aa"
a{2,3} matches "aa" or "aaa"
so on and so on: heres more on the syntax
http://www.php.net/manual/en/pcre.pattern.syntax.php