String match for domain name : String Matches « String « PHP

String match for domain name

function simple_dot_com ($url) {
  return(ereg('^www\.[a-z]+\.com$', $url));

$urls_to_test = 
   array('', '', 
         '', '', 
         '', '', 
         'www.Web addresses can\'t have');

while($test = array_pop($urls_to_test)){
  if (simple_dot_com($test))
    print("\"$test\" is a simple dot-com<BR>");
    print("\"$test\" is NOT a simple dot-com<BR>");



Related examples in the same category

1.A simple use of preg_match()
2.String matches: ^ (begine)
3.String match demo: /[cd][oa][gt]/
4.String match demo: |
5.$: anchors a pattern to the end of a line or the end of the string
6.String matches: string start
7.String match and if statement