I am abit of the amateur if this involves regex but consider i've the next three domain names

world wide web.google.com

world wide web.google.co.united kingdom

google.com

I must create some regex which will test to ascertain if the domain includes a world wide web in addition to a .co.united kingdom or .com

Does anybody are conscious of some regex which will test with this?

Thanks

You do not need regex with this , you should use strpos witch is sayd to become faster than regex .

if ( strpos('www.', $mystring) !== false ) world wide web was based in the string

 else world wide web wasn't foun within the string



Should you realy whant to become reduced and employ regex you can look at its them such as this

preg_match('/world wide web.com.co.united kingdom/', $mystring)

If for instance you whant to use different logic for world wide web compared to .com you should use

preg_match('/world wide web/', $string)

preg_match('/.com/', $string)

preg_match('/.co.united kingdom/', $string)

Do this:

/^world wide web.*(?:comco.united kingdom)$/

From things i understand out of your question, the domain needs to begin with world wide web AND finishes with either .co.united kingdom OR .com. So this is actually the RegExp:

<?php

    $domain names = array(

        "world wide web.google.com",

        "world wide web.google.co.united kingdom",

        "google.com"

    )

    foreach($domain names as $domain)united kingdom.com)$@", $domain)

        )

    

?>

Simple

$ar = array()

$t = array("world wide web.google.com","world wide web.google.co.united kingdom","google.com","world wide web.google")

foreach ($t as $str) united kingdom.com)$/',$str)) 



Conditional

$ar = array()

$t = array("world wide web.google.com","world wide web.google.co.united kingdom","google.com","world wide web.google")

foreach ($t as $str) situation preg_match('/^www.(.*)$/',$str) :

        // code

        situation preg_match('/^(.*)(.co.united kingdom)$/',$str) :

        // code

        situation preg_match('/^(.*)(.com)$/',$str) :

        // code

        break