当然是!
在Firebug控制台中运行它
"®ü".replace(/[®ü]/g,"replaced")
Run Code Online (Sandbox Code Playgroud)
回
"replacedreplaced"
你也可以
"®ü".replace(/[\xAE\xFC]/g,"Wohoo! ");
Run Code Online (Sandbox Code Playgroud)
返回
"Wohoo! Wohoo! "
Run Code Online (Sandbox Code Playgroud)
可以在http://www.ascii.cl/htmlcodes.htm找到一个好的十六进制符号查找页面
例
在这个页面上运行这个jQuery
$(".post-text").text().replace(/®/g," ******** ")
Run Code Online (Sandbox Code Playgroud)
回报
" is it possible to translate special characters like ******** , ü etc with javascript
String replace function? Use this syntax... string.replace(/\xCC/g/,''); Where 'CC' is
the hex character code for the char you are wanting to replace. In this example I am
replacing with empty string ''. yes, and is as simple as can be: ' ******** '.replace('
******** ','anything'); Sure is! Running this in the Firebug console " ******** ü".
replace(/[ ******** ü]/g,"replaced") returned replacedreplaced "
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8789 次 |
| 最近记录: |