Removing characters with Jquery

2

Is it possible to remove a specific character with jquery? I'm trying to remove the character '' character ball that is in the database of a site I'm reshaping. That is, I have access to all HTMLs and CSSs less than content. So my list already has a specific Style but in the database there is this damn typed character.

    
asked by anonymous 20.01.2015 / 18:56

3 answers

4

does not have some basic rules that can be solved reassignment with javascript such as data type conversions, data type identification, value rounding, and string substitution.

So you can solve this with javascript:

var str = "• Este é um texto de teste!•••";
var res = str.replace(/•/g, "");

document.getElementById("texto").innerHTML = res;
<span id="texto"></span>

To solve this same problem with jQuery would be as follows

var str = $("#texto").text();
var res = str.replace(/•/g, "");

$("#texto").text(res);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><spanid="texto">• Este é um texto de teste!•••</span>
    
20.01.2015 / 19:14
5

Use a regular expression:

var mystring = "• este é um teste"
mystring.replace(/•/g , "");

You can pick up and change content with $('seletor').html() . The advantage of using regular expression instead of replace () is that replace () only changes the first occurrence.

    
20.01.2015 / 19:11
3

You can use .split () to split the string and then rejoin it with the .join () :

"•bolinhas • bolinhas•".split('•').join(''); // dá "bolinhas  bolinhas"

Using split / join is faster than using regular expressions .

So you can do a function to clean up strings:

function limparBolinhas(str){
    return str.split('•').join('');
}

and use it as needed.

    
20.01.2015 / 19:52