Quantcast
Channel: How to replace all characters in a string? - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by jValdron for How to replace all characters in a string?

If you simply pass '^' to the JavaScript replace function it should be treated as a string and not as a regular expression. However, using this method, it will only replace the first character. A...

View Article



Answer by aefxx for How to replace all characters in a string?

function r(t, o, n) { return t.split(o).join(n);}

View Article

Answer by Elias Dorneles for How to replace all characters in a string?

Use a RegExp object instead of a simple string:text.replace(new RegExp(oldChar, 'g'), newChar);

View Article

How to replace all characters in a string?

I have a string that is passed by parameter and I have to replace all occurrences of it in another string, ex:function r(text, oldChar, newChar){ return text.replace(oldChar, newChar); // , "g")}The...

View Article
Browsing latest articles
Browse All 4 View Live


Latest Images