Ali
Ali

Reputation: 3615

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

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

I have problem during comparing two strings . Above mentioned symbol is append when I compute difference. I also test it in my local application please check link below.

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

Upvotes: 3

Views: 3532

Answers (3)

ziesemer
ziesemer

Reputation: 28687

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

Yields:

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

This will remove all occurrences of the character. No jQuery necessary - just vanilla browser-provided JavaScript.

Some additional details are available at https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace.

Upvotes: 6

Brian
Brian

Reputation: 2229

javascript replace function should work. If it isn't finding the character then try using the unicode or ansi equivalent.

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

Upvotes: 0

Rory McCrossan
Rory McCrossan

Reputation: 337560

jQuery isn't needed for this, you can achieve it by using native javascripts replace function:

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

Example fiddle

Upvotes: 1

Related Questions