Detect URLs in text with JavaScript

后端 未结 13 2204
孤城傲影
孤城傲影 2020-11-22 06:23

Does anyone have suggestions for detecting URLs in a set of strings?

arrayOfStrings.forEach(function(string){
  // detect URLs in strings and do something sw         


        
13条回答
  •  执笔经年
    2020-11-22 06:58

    If you want to detect links with http:// OR without http:// OR ftp OR other possible cases like removing trailing punctuation at the end, take a look at this code.

    https://jsfiddle.net/AndrewKang/xtfjn8g3/

    A simple way to use that is to use NPM

    npm install --save url-knife
    

提交回复
热议问题