You have to find >
(greater than) in Regex and replace with <
.
Read more here
<p id="demo">this > and this > symbol should be replaced.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var res = str.replace(/>/g, "%3E");
document.getElementById("demo").innerHTML = res;
}
</script>
I need to change > to %3E .., if the > symbol is changed by another symbol, everything works fine.
How can I correct this?
<p id="demo">this > and this > symbol should be replaced.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var res = str.replace(/>/g, "%3E");
document.getElementById("demo").innerHTML = res;
}
if i change to test: (/> / g, “% 3E”) in (/> / g, “RED”) still does not work. He just doesn’t want to change me < or >
Thanks for the reply Ritesh Khandekar. I think your answer is definitely correct, but if I insert it into my notepad ++ where I code it doesn’t work .. I’m wrong somewhere. I write after the test. I don’t know why so many minuses on the question. 🙁
@maja, why are you expecting any DOM method to work inside notepad++? notepad++ is a text editor, not a browser. There is no DOM in notepad++ and therefore you shouldn’t expect web javascript scripts to magically work just because the contents of your file happens to be the source of a web page. However, if you open that file in a browser, the script will work correctly.
@maja I think you should take care of everything in Regex, even a space. And i think community want you to edit your question and be specific on one problem.