-1

Here is my string value:

var _str = "please visit http://www.sample.com for more infomation"

I have to display the underlined URL part alone like:

http://www.sample.com

TIA

surya
  • 191
  • 1
  • 8
  • Your examples doesn't match each other. You probably just need to use a [regex](https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url). – GalAbra Jun 17 '18 at 12:35
  • Would you like to take only URL part from string? Use Regular Expression. – Benyi Jun 17 '18 at 12:35
  • This is bad design, you should but the URL in a separate variable – olfek Jun 17 '18 at 12:51

1 Answers1

1

Use regular expression. Check below pattern, I hope this will work for you.

var str = "please visit http://www.sample.com for more infomation"

var result= str.match(/\bhttps?:\/\/\S+/gi);
לבני מלכה
  • 15,925
  • 2
  • 23
  • 47
Kuldeep
  • 83
  • 1
  • 9