I've a php code, it prints some text. But I need to replace "n" character with "N" by JavaScript (without editing php code). In everywhere (All texts). How can I do it? Thanks ...
PS: I was creating another topic (#4459901), but this topic is different!
3 Answers 3
Before I write this: I don't recommend it. Doing this before outputting to the browser would be your best bit. It's also not great for single characters because it will replace all instances of n with N (i.e. <span> will become <spaN>.
document.body.innerHTML= document.body.innerHTML.replace(/n/g, "N");
Example: http://jsfiddle.net/jonathon/x4akZ/
1 Comment
Use:
replaced = str.replace(/n/g, "N");
Comments
You have just to use the replace function, and after your regex, ou must uso /g which means that you want to replace all chars.
"non".replace(/n/g, 'N')