Basically what I want is to have a html textarea field, where the user can write a comment. If the user writes a url, I want to highlight this url. Example bellow:
"Hi! This is a comment. This is a link to http://www.google.com and the comment continues."
I want my regular expression to match urls formatted as follows:
- http://google.com
- http://www.google.com
- www.google.com
I don't want to match urls formatted as follows
- google.com
- www.com
So far my regular expression looks like this:
/(http)?(s)?(:\/\/)?((w*\.)([a-zA-Z0-9])([-\w]+\.)+([^\s\.]+[^\s]*)+[^,.\s])/
but the problem is that it cannot match http://google.com (1) of the list above.
I know that this topic may be marked as duplicate and I apology but I wasn't able to find exactly what I need anywhere. Any help is appreciated :)