答案 0 :(得分:0)
您可以使用正则表达式替换:
$("#txtarea").keyup(function(){
console.log(this.value);
this.value = this.value.replace(/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/, ' ');
})
使用方括号regex (?:http?:\/\/)?(?:[\w]+\.)(?:\.?[\w]{2,})+$
$("#txtarea").keyup(function(){
console.log(this.value);
this.value = this.value.replace(/(?:http?:\/\/)?(?:[\w]+\.)(?:\.?[\w]{2,})+$/, ' ');
})