简体   繁体   中英

Javascript regex unable to replace certain special characters

I have this Javascript regex:

 body = body.replace(/[\x80-\xFF]/g,"#");

which I am hoping to use to replace characters in the table here . However I am unable to replace the characters highlighted in red on the table in that page. I couldn't comprehend why. Can someone enlighten me on why it is happening like that and what the workaround? Thank you.

一种解决方法是改用Unicode范围,当我在控制台的示例页面上尝试此方法时(我认为您要这样做):

document.body.innerHTML = document.body.innerHTML.replace(/[\u0152-\u2122]/g,"#");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM