php - Regular expression that matches specific url format in textarea field -
basically want have html textarea field, user can write comment. if user writes url, want highlight url. example bellow:
"hi! comment. link http://www.google.com , comment continues."
i want regular expression match urls formatted follows:
- http://google.com
- http://www.google.com
- www.google.com
i don't want match urls formatted follows
- google.com
- www.com
so far regular expression looks this:
/(http)?(s)?(:\/\/)?((w*\.)([a-za-z0-9])([-\w]+\.)+([^\s\.]+[^\s]*)+[^,.\s])/
but problem cannot match http://google.com (1) of list above.
i know topic may marked duplicate , apology wasn't able find need anywhere. appreciated :)
Comments
Post a Comment