var strFindWebSites=/^\(?[http]\)?[\. ]?[www][\. ]?[com]$/g;
if (strFindWebSites.test(theForm.theTextArea.value)) {
...
Code:
var strFindWebSites=/^\(?([http])\)?[\. ]?([www])[\. ]?([com])$/g;
if (strFindWebSites.test(theForm.theTextArea.value)) {
...
Code:
var strFindWebSites=/^\(?(http)\)?[\. ]?(www)[\. ]?(com)$/g;
if (strFindWebSites.test(theForm.theTextArea.value)) {
...
I realize that there are so many ways that people could enter a web site address, and I'm not trying to capture every possible way. Simply trying to capture the more common ways, and those that would include a space in them.
I'm not looking for domain forwards or domain error handling.
Just wanting to detect if anyone has inputed any textarea information that contains a web site address, as above.
I've gotten this to work, just not sure this is the "best" way to approach this:
Code:
var strFindWebSites=["www", "w w w", "http", "h t t p", "href", "h r e f", ".com", "dot com", ".net", "dot net"];
var searchExp = new RegExp(strFindWebSites.join("|"),"gim");
if (searchExp.test(theForm.theTextArea.value)) {
...
I also realize that there is a chance that someone might type in something other than a web address with "polka dot netting" <-- That would be caught by "dot net"
How could I find the whole word string "dot net" only (in this case)?
Bookmarks