How would i find if a domain e.g.

1) www.example.com.au
2) www.example.com
3) example.com.au
4) example.com


The way I was doing it was like this(see below) but it will find www.example.com if www.example.com.au exists it the text. Also if the domain does not start with www. (4) it would find (3) and or (4) for example thebestexample.com

i was checking the source from a google search:
Code:
ress.com/2009/09/15/i-belive-that-this-is-an-example-of-a-good-landing/+this+is+an+example&amp;cd=2&amp;hl=en&amp;ct=clnk&amp;gl=au&amp;ie=UTF-8&amp;source=www.google.com.au">Cached</a></span></span></div><li class=g><h3 class="r"><a href="http://www.monaropioneers.com/example.htm" class=l><em>EXAMPLE</em> ONLY This is a good <em>example</em> of an informative family <b>...</b></a></h3><div class="s"><em>EXAMPLE</em> ONLY - This is a good <em>example</em> of an informative family profile. JOHN SETTLER Nimmitabel Station 1835 (Earliest available family photos, photos of a <b>...</b><br><span class=f><cite>www.monaropioneers.com/<b>example</b>.htm</cite> - <span class=gl><a href="http://webcache.googleusercontent.com/search?q=cache:pmjqyGjP5doJ:www.monaropioneers.com/example.htm+this+is+an+example&amp;cd=3&amp;hl=en&amp;ct=clnk&amp;gl=au&amp;ie=UTF-8&amp;source=www.google.com.au">Cached</a> - <a href="/search?hl=en&amp;cr=countryAU&amp;ie=UTF-8&amp;q=related:www.monaropioneers.com/example.htm+this+is+an+example&amp;tbo=1&amp;sa=X&amp;ei=z72nTZXfCIu8vQO7pPH8CQ&amp;ved=0CDIQHzAC">Similar</a></span></span></div><li class=g><span class="b w xsm">[PDF]</span> <h3 class="r"><a href="http://www.anz.com.au/Documents/AU/Investor/agm/CEO%20Final.PDF" class=l><em>This is an example</em></a></h3><div class="s"><span class=f>File Format:</span> PDF/Adobe Acrobat - <a href="http://docs.google.com/viewer?a=v&q=cache:S80Uz5HYntsJ:www.anz.com.au/Documents/AU/Investor/agm/CEO%2520Final.PDF+this+is+an+example&hl=en&gl=au&pid=bl&srcid=ADGEESiwysQp16HJo_IQAvt0UEcFr-46aKQzGdvvziUlfdt_uH5HuvLW_lsarOs1nYz7sealESnrupSGhDCvnF5VtKY2P3XQnhjTDtVdkFvxwC1WsmICAPvm3pFW4hYq5gfK9yVPn29f&sig=AHIEtbQD9OBVEzX4OQ_8D4JCjr3ATqjTLg" class=fl>Quick View</a><br><span class=f><i>Your browser may not have a PDF reader available. Google recommends visiting our <a href="http://webcache.googleusercontent.com/search?q=cache:S80Uz5HYntsJ:www.anz.com.au/Documents/AU/Investor/agm/CEO%2520Final.PDF+this+is+an+example&amp;cd=4&amp;hl=en&amp;ct=clnk&amp;gl=au&amp;ie=UTF-8&amp;source=www.google.com.au">text version</a> of this document.</i></span><br>ANZ has been transformed over the past decade. 0.8. 2.8. 1994. 2004. Net Profit after Tax (A$b). 13% Compound Growth <b>...</b><br><span class=f><cite>www.anz.com.au/Documents/AU/Investor/agm/CEO%20Final.PDF</cite><span class=gl></span></span></div><li class=g><span class="b w xsm">[DOC]</span> <h3 class="r"><a href="http://conference.herdsa.org.au/2011/files/Template%20for%20full%20refereed%20papers_2011.doc" class=l>TEMPLATE FOR FULL REFEREED PAPERS (DOC 51kb) - HERDSA 2008 <b>...</b></a></h3><div class="s"><span class=f>File Format:</span> Microsoft Word - <a href="http://docs.google.com/viewer?a=v&q=cache:UKZu9gbeVGkJ:conference.herdsa.org.au/2011/files/Template%2520for%2520full%2520refereed%2520papers_2011.doc+this+is+an+example&hl=en&gl=au&pid=bl&srcid=ADGEESgPoFTWyZAsRTB-sDBS8fPawGBh8HYGHPutcabTUi7soUYsozMItIdGWsV0plaff00wj8rrFiIxiS4bXp2d-DyBT35UzHj385AOBdApktNpCJA1PE25263qAGcOCuseszfF4d-j&sig=AHIEtbRBxlFX1WAT_kTTy5VAk4k5V7BDIg" class=fl>Quick View</a><br><em>This is an example</em> of the body text style. <em>This is an example</em> of the body text: · <em>Example</em> level 1 bullet list. · <em>Example</em> level 1 bullet list <b>...</b><br><span class=f><cite>conference.herdsa.org.au/.../Template%20for%20full%20refereed%20papers _2011.doc</cite> - <span class=gl><a href="/search?hl=en&amp;cr=countryAU&amp;ie=UTF-8&amp;q=related:conference.herdsa.org.au/2011/files/Template%2520for%2520full%2520refereed%2520papers_2011.doc+this+is+an+example&amp;tbo=1&amp;sa=X&amp;ei=z72nTZXfCIu8vQO7pPH8CQ&amp;ved=0CDkQHzAE">Similar</a></span></span></div><li class=g><h3 class="r"><a href="http://www.beckattbengals.com.au/allbengals.html" class=l>Beckatt Bengals - Information about the Bengal Breed</a></h3><div class="s">This is (sgc sierragold phoenix rising) whom is  a prime <em>example</em> of a stunning marble cat. <b>...</b> <em>This is an example</em> of the seal sepia pattern type <b>...</b><br><span class=f><cite>www.beckattbengals.com.au/allbengals.html</cite> - <span class=gl><a href="http://webcache.googleusercontent.com/search?q=cache:7VjA_shs-2QJ:www.beckattbengals.com.au/allbengals.html+this+is+an+example&amp;cd=6&amp;hl=en&amp;ct=clnk&amp;gl=au&amp;ie=UTF-8&amp;source=www.google.com.au">Cached</a> - <a href="/search?hl=en&amp;cr=countryAU&amp;ie=UTF-8&amp;q=related:www.beckattbengals.com.au/allbengals.html+this+is+an+example&amp;tbo=1&amp;sa=X&amp;ei=z72nTZXfCIu8vQO7pPH8CQ&amp;ved=0CD0QHzAF">Similar</a></span></span></div><li class=g><h3 class="r"><a href="http://scottdesapio.com/VBScriptOAuth/" class=l>Classic ASP VBScript OAuth</a></h3><div class="s">This page hosts an <em>example</em> of a Generic Classic ASP VBScript OAuth Library in action. The <em>example</em> uses Twitter's OAuth Authentication Flow to illustrate usage .<br><span