I have three quick questions that I hope the more experienced can help me with. 1.
What is the best way to check if a string is in "www.site.com" format? but not restricted to .com
also to .co.uk
and others etc
I just want a method to check that a given string is a web
I also want to parse the string incase http://
was added to the string, and want to remove the http:// from the string.
echo -a $regex(http://www.google.co.uk/,^^%*(&*%$%$^@%whatever else you geeks put here)
will return "www.google.co.uk"
without the http://
I am aware I could use $remove or maybe even tokens, but would like a regex. 3.
If the string contains a URL I just want to return the base URL, not the directories after it. For example http://www.forums.mirc.com/ubbthreads.php?ubb=newpost&Board=5
will return "www.forums.mirc.com"
p.s I wonder if all these questions could be done in one function, like an alias. One;
to check if its in the format "www.site.com" and it not to return false.Second
; if it is a URL but is prefixed by http://
to remove the http:// and return the URL beginning with www. Third;
To return the base URL as mentioned in my previous example.
I hope I have not confused anybody.
Thanks in advance for any replies.