1

I have comment section of page where user can post the comments on uploaded content, I want to check if user has shared any url links in his comment.

for Example -

var comment = "To search more on this question you can look to http://stackoverflow.com/ "

Now How do I find out that it is URL link and retrieve that link?I would be great if I can find a way to do this in Jquery and Java Script but PHP is also acceptable.

Thanks in advance.

Hitesh
  • 4,098
  • 11
  • 44
  • 82

1 Answers1

1

Try to use this REGEX

((http:\/\/|https:\/\/)?(www.)?(([a-zA-Z0-9-]){2,}\.){1,4}([a-zA-Z]){2,6}(\/([a-zA-Z-_\/\.0-9#:?=&;,]*)?)?)
OpenStark
  • 476
  • 2
  • 8