How can I hide text that is enclosed in braces in my div
Ex:
<div> Hello {World} </div>
How can I hide text that is enclosed in braces in my div
Ex:
<div> Hello {World} </div>
Using Regular Expression
var text = $("div").text();
$("div").html('').append(text.replace(/(\s\{.*?\})/, ''))
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div> Hello {World} </div>
Hello, try this regular expression:
let getDiv = document.querySelector('.teste').innerHTML;
let newTeste = getDiv.replace(/(\s\{.*?\})/, '');
document.querySelector('.teste').innerHTML = newTeste;
<div class="teste">Hello {World} !</div>
Take the div text, make a replace using regular expression
var textoDaDiv = $("div").text();
$("div").text(textoDaDiv.replace(/ *\{[^)]*\} */g, ""));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div> Hello {World} </div>