0

I am trying to create and application that automatically filters links from strings. I have a JSON with all the mainstream domain endings like .com, .net, .org, etc.

If I had a string similar to "The link is test.com", how would I filter it to just the link? I need this to work for any sentence though, the sentence above is just an example. Would the method also work with links such as test.com/test123?

puds
  • 1
  • Welcome to Stack Overflow! Please visit [help], take [tour] to see what and [ask]. ***[>>>Do some research<<<](https://www.google.com/search?q=javascript+regex+link+without+http+site:stackoverflow.com)***, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output, preferably in a [Stacksnippet](https://blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/) – mplungjan Feb 08 '21 at 08:23
  • For example this regex will handle most except a link ending in a question mark `/\w+\.\w+[\/]?[^ ]+/gm` https://regex101.com/r/WimfuN/1 - you can filter those after if needed – mplungjan Feb 08 '21 at 08:34

0 Answers0