var url="�http://www.theaustralian.com.au/australian-it/it-business/eugene-kaspersky-queries-breach-rules/story-e6frganx-1226656443211�"
我想使用JavaScript正則表達式在URL的開頭和結尾去除Unicode特殊字符。如何在JavaScript中使用正則表達式從字符串(URL)中刪除unicode特殊字符
var url="�http://www.theaustralian.com.au/australian-it/it-business/eugene-kaspersky-queries-breach-rules/story-e6frganx-1226656443211�"
我想使用JavaScript正則表達式在URL的開頭和結尾去除Unicode特殊字符。如何在JavaScript中使用正則表達式從字符串(URL)中刪除unicode特殊字符
這將做:
/^[^\w]+|[^\w]+$/mg
var url="�http://www.theaustralian.com.au/australian-it/it-business/eugene-kaspersky-queries-breach-rules/story-e6frganx-1226656443211�";
alert(url.replace(/^[^\w]+|[^\w]+$/mg, ""));
感謝佩德羅的解決方案! –
非常歡迎@KiranBodige :)如果我的答案對您有幫助,請考慮投票1 +▲,並通過點擊選中標記✔在投票箭頭中間接受它作爲正確答案,tks! –
'URL = url.replace(/ \ uFFFD /克, '')'?要獲得正確的十六進制代碼,您可以隨時使用[r12a >> apps >> Unicode代碼轉換器](http://r12a.github.io/apps/conversion/)。 –
'var res = url.substring(1,url.length-1)''? ;) –
什麼是「unicode特殊字符」? –