第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何實(shí)時(shí)替換編輯器內(nèi)的文本成為鏈接?

如何實(shí)時(shí)替換編輯器內(nèi)的文本成為鏈接?

例如知乎編輯器內(nèi),如果粘貼了一段網(wǎng)址,會(huì)自動(dòng)轉(zhuǎn)換為鏈接。stack上找到的代碼不知道該如何用,大家可以看看。functionreplaceURLWithHTMLLinks(text){varexp=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;returntext.replace(exp,"$1");}是監(jiān)視keyup來替換的嗎?希望得到大家的解答!謝謝!***//Update:2013-12-09:***編輯器為
查看完整描述

2 回答

?
拉丁的傳說

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊

linkify:function(inputText){
varreplacedText,replacePattern1,replacePattern2,replacePattern3;
varoriginalText=inputText;
//URLsstartingwithhttp://,https://,file://orftp://
replacePattern1=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
//URLsstartingwith"www."(without//beforeit,orit'dre-linktheonesdoneabove).
replacePattern2=/(^|[^\/f])(www\.[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
//Changeemailaddressestomailto::links.
replacePattern3=/(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gi;
//Iftherearehrefsintheoriginaltext,let'ssplit
//thetextupandonlyworkonthepartsthatdon'thaveurlsyet.
varcount=originalText.match(/if(count.length>0){
varcombinedReplacedText;
//Keepdelimiterwhensplitting
varsplitInput=originalText.split(/(<\/a>)/g);
for(i=0;iif(splitInput[i].match(/splitInput[i]=splitInput[i].replace(replacePattern1,'$1').replace(replacePattern2,'$1$2').replace(replacePattern3,'$1');
}
}
combinedReplacedText=splitInput.join('');
returncombinedReplacedText;
}else{
replacedText=inputText.replace(replacePattern1,'$1');
replacedText=replacedText.replace(replacePattern2,'$1$2');
replacedText=replacedText.replace(replacePattern3,'$1');
returnreplacedText;
}
},
對(duì)一段文本,可重復(fù)運(yùn)行。
                            
查看完整回答
反對(duì) 回復(fù) 2019-04-08
  • 2 回答
  • 0 關(guān)注
  • 440 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)