Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript contenteditable内部的JS正则表达式匹配URL';我不能正常使用www*_Javascript - Fatal编程技术网

Javascript contenteditable内部的JS正则表达式匹配URL';我不能正常使用www*

Javascript contenteditable内部的JS正则表达式匹配URL';我不能正常使用www*,javascript,Javascript,我有一个contenteditable,用户可以在其中编写以下内容: Hello You should be doing this slightly different. My answer however is not perfect though; URLs are tricky business. function go(){ var html = $('.content').html(); html = html.replace(/(?:(?:(?:https?|ftps?)?:

我有一个
contenteditable
,用户可以在其中编写以下内容:

Hello
You should be doing this slightly different. My answer however is not perfect though; URLs are tricky business.

function go(){
  var html = $('.content').html();
  html = html.replace(/(?:(?:(?:https?|ftps?)?:?)\/\/)?w{3,}.?(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?/igm, (url) => '<a target="_blank" href="' + url + '">' + url + '</a>');
  $('.result').html(html);
}
你好
你应该做些稍微不同的事情。然而,我的答案并不完美;URL是一项棘手的业务

函数go(){ var html=$('.content').html(); [3,}.....(((((::::((:::::(((::))除了除了除了除了除了其他3,}.....((((::以下以下:::::::(((((::::((((:::((:::(((:::::(((::::)除除除除除上述3,)其他3,{{{{3,3,,,,))3,,,,,)其他3,{{{{3,,,,,,,,,,,,{{{{{3,,,,,,,((((((((((::::::::::::::::::以下以下以下以下以下以下以下以下以下以下以下)3,{{3,{{{{{3,,,,,,,,,,{{{{3,,,,,,,(?:[1-9]\d?\d | 1\d | 2[01]\d | 22[0-3])(?:\(?:[1,2}2[0-4]\d | 25[0-5]){2(?:(?:[1-9]\d | 1\d | 2[0-4]\d | 25[0-4]))(?:(?:[a-z0 9\UFA1-][a-z0-9\u00a1-\uffff-]{0,62})?[a-z0-9\u00a1-\uffff]\+(?:[a-z\u00a1-\uffff]{2,5})(?:\d{2,5})(?:[/?#]\S*)/igm,(url=>”); $('.result').html(html); }
所有其他子域、子域和…?这将引发错误,有关URL正则表达式的更多帮助以及为什么这很难,请使用google perfect URL正则表达式有一个图表。请确保通过链接列表运行它,如果它以您不喜欢的方式失败,请重试!:D