如何使用jquery¶删除字符串中的以下符号/特殊字符;

How to remove following symbol/special character in string using jquery ¶

本文关键字:符号 特殊字符 字符串 jquery 何使用 #182 删除      更新时间:2023-09-26

如何使用jquery 删除字符串中的以下符号/特殊字符

我在比较两个字符串时遇到问题。上面提到的符号是我计算差值时附加的。我还在本地应用程序中测试它请查看下面的链接。

http://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/demo_diff.html

var s = "This is a string that contains ¶, a special character.";
s = s.replace(/¶/g, "");

收益率:

"This is a string that contains , a special character."

这将删除所有出现的字符。不需要jQuery,只需要普通浏览器提供的JavaScript。

有关更多详细信息,请访问https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace.

jQuery不需要,您可以通过使用本地javascript replace函数来实现它:

var myString = "ABC¶DEFG"
alert(myString.replace("¶", ""))

小提琴示例

javascript替换函数应该可以工作。如果找不到字符,请尝试使用unicode或等效的ansi。

http://www.alanwood.net/demos/ansi.html